Skip to content

Commit da75191

Browse files
committed
fix stop node expression when ns prefix is removed
1 parent 31bbc99 commit da75191

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

spec/stopNodes_spec.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,4 +450,27 @@ describe("XMLParser StopNodes", function () {
450450
expect(result).toEqual(expected);
451451

452452
});
453+
454+
it("(PR #818) should parse stop node when namespace is set to be removed", function () {
455+
456+
const xmlData = `<root><ns:code>safe <ns:code>nested</ns:code> still raw</ns:code></root>`;
457+
const options = {
458+
stopNodes: ["root.ns::code"],
459+
removeNSPrefix: true
460+
};
461+
462+
const expected = {
463+
"root": {
464+
"code": "safe <ns:code>nested</ns:code> still raw"
465+
}
466+
}
467+
468+
// const result = XMLValidator.validate(xmlData)
469+
const parser = new XMLParser(options);
470+
const result = parser.parse(xmlData);
471+
472+
// console.log(JSON.stringify(result, null, 4));
473+
expect(result).toEqual(expected);
474+
475+
});
453476
});

src/xmlparser/OrderedObjParser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ function readStopNodeData(xmlData, tagName, i) {
776776
const closeIndex = findClosingIndex(xmlData, "]]>", i, "StopNode is not closed.") - 2;
777777
i = closeIndex;
778778
} else {
779-
const tagData = readTagExp(xmlData, i, '>')
779+
const tagData = readTagExp(xmlData, i, false)
780780

781781
if (tagData) {
782782
const openTagName = tagData && tagData.tagName;

0 commit comments

Comments
 (0)