mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-23 09:51:10 +01:00
Move everything into subdir for repo merge
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
import { DOMParser } from '@xmldom/xmldom';
|
||||
import { PluginDefinition } from '@yaakapp/api';
|
||||
import xpath from 'xpath';
|
||||
|
||||
export const plugin: PluginDefinition = {
|
||||
filter: {
|
||||
name: 'XPath',
|
||||
description: 'Filter XPath',
|
||||
onFilter(_ctx, args) {
|
||||
const doc = new DOMParser().parseFromString(args.payload, 'text/xml');
|
||||
const result = xpath.select(args.filter, doc, false);
|
||||
|
||||
if (Array.isArray(result)) {
|
||||
return { filtered: result.map(r => String(r)).join('\n') };
|
||||
} else {
|
||||
// Not sure what cases this happens in (?)
|
||||
return { filtered: String(result) };
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user