mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-22 16:48:30 +02:00
Don't return "undefined" when no XPath match
This commit is contained in:
@@ -14,8 +14,9 @@ export const plugin: PluginDefinition = {
|
|||||||
try {
|
try {
|
||||||
const doc = new DOMParser().parseFromString(String(args.values.input), 'text/xml');
|
const doc = new DOMParser().parseFromString(String(args.values.input), 'text/xml');
|
||||||
let result = xpath.select(String(args.values.query), doc, false);
|
let result = xpath.select(String(args.values.query), doc, false);
|
||||||
|
console.log("RESULT", result);
|
||||||
if (Array.isArray(result)) {
|
if (Array.isArray(result)) {
|
||||||
return String(result.map(c => String(c.firstChild))[0]);
|
return String(result.map(c => String(c.firstChild))[0] ?? '');
|
||||||
} else if (result instanceof Node) {
|
} else if (result instanceof Node) {
|
||||||
return String(result.firstChild);
|
return String(result.firstChild);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user