fast-xml-parser
Advanced tools
Comparing version 4.2.0 to 4.2.1
Note: If you find missing information about particular minor version, that version must have been changed without any functional change in this library. | ||
**4.2.1 / 2023-04-18** | ||
* fix: jpath after unpaired tags | ||
**4.2.0 / 2023-04-09** | ||
@@ -4,0 +7,0 @@ * support `updateTag` parser property |
{ | ||
"name": "fast-xml-parser", | ||
"version": "4.2.0", | ||
"version": "4.2.1", | ||
"description": "Validate XML, Parse XML, Build XML without C/C++ based libraries", | ||
@@ -5,0 +5,0 @@ "main": "./src/fxp.js", |
@@ -209,4 +209,13 @@ 'use strict'; | ||
jPath = jPath.substr(0, jPath.lastIndexOf(".")); | ||
//check if last tag of nested tag was unpaired tag | ||
const lastTagName = jPath.substring(jPath.lastIndexOf(".")+1); | ||
let propIndex = 0 | ||
if(lastTagName && this.options.unpairedTags.indexOf(lastTagName) !== -1 ){ | ||
propIndex = jPath.lastIndexOf('.', jPath.lastIndexOf('.')-1) | ||
if(propIndex < 1) propIndex = jPath.lastIndexOf("."); | ||
}else{ | ||
propIndex = jPath.lastIndexOf("."); | ||
} | ||
jPath = jPath.substring(0, propIndex); | ||
currentNode = this.tagsNodeStack.pop();//avoid recursion, set the parent tag scope | ||
@@ -288,6 +297,2 @@ textData = ""; | ||
if(tagName !== xmlObj.tagname){ | ||
jPath += jPath ? "." + tagName : tagName; | ||
} | ||
//check if last tag was unpaired tag | ||
@@ -297,4 +302,7 @@ const lastTag = currentNode; | ||
currentNode = this.tagsNodeStack.pop(); | ||
jPath = jPath.substring(0, jPath.lastIndexOf(".")); | ||
} | ||
if(tagName !== xmlObj.tagname){ | ||
jPath += jPath ? "." + tagName : tagName; | ||
} | ||
if (this.isItStopNode(this.options.stopNodes, jPath, tagName)) { //TODO: namespace | ||
@@ -306,3 +314,3 @@ let tagContent = ""; | ||
} | ||
//boolean tag | ||
//unpaired tag | ||
else if(this.options.unpairedTags.indexOf(tagName) !== -1){ | ||
@@ -350,4 +358,4 @@ i = result.closeIndex; | ||
} | ||
this.addChild(currentNode, childNode, jPath) | ||
jPath = jPath.substr(0, jPath.lastIndexOf(".")); | ||
this.addChild(currentNode, childNode, jPath) | ||
} | ||
@@ -354,0 +362,0 @@ //opening tag |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
103631
1961