mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-05-02 05:24:18 +02:00
Add @yaakapp/api everywhere
This commit is contained in:
@@ -1,10 +1,17 @@
|
||||
import { DOMParser } from '@xmldom/xmldom';
|
||||
import { YaakContext } from '@yaakapp/api';
|
||||
import xpath from 'xpath';
|
||||
|
||||
export function pluginHookResponseFilter(
|
||||
_ctx: any,
|
||||
_ctx: YaakContext,
|
||||
{ filter, body }: { filter: string; body: string },
|
||||
) {
|
||||
const doc = new DOMParser().parseFromString(body, 'text/xml');
|
||||
return `${xpath.select(filter, doc)}`;
|
||||
const result = xpath.select(filter, doc, false);
|
||||
if (Array.isArray(result)) {
|
||||
return result.map(r => String(r)).join('\n');
|
||||
} else {
|
||||
// Not sure what cases this happens in (?)
|
||||
return String(result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user