Don't return "undefined" when no XPath match

This commit is contained in:
Gregory Schier
2025-05-28 13:14:32 -07:00
parent 053cbe49f9
commit 399cd35b2b

View File

@@ -14,8 +14,9 @@ export const plugin: PluginDefinition = {
try {
const doc = new DOMParser().parseFromString(String(args.values.input), 'text/xml');
let result = xpath.select(String(args.values.query), doc, false);
console.log("RESULT", 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) {
return String(result.firstChild);
} else {