Skip to content
This repository was archived by the owner on May 29, 2025. It is now read-only.

Commit 399cd35

Browse files
committed
Don't return "undefined" when no XPath match
1 parent 053cbe4 commit 399cd35

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

  • plugins/template-function-xml/src

plugins/template-function-xml/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ export const plugin: PluginDefinition = {
1414
try {
1515
const doc = new DOMParser().parseFromString(String(args.values.input), 'text/xml');
1616
let result = xpath.select(String(args.values.query), doc, false);
17+
console.log("RESULT", result);
1718
if (Array.isArray(result)) {
18-
return String(result.map(c => String(c.firstChild))[0]);
19+
return String(result.map(c => String(c.firstChild))[0] ?? '');
1920
} else if (result instanceof Node) {
2021
return String(result.firstChild);
2122
} else {

0 commit comments

Comments
 (0)