Skip to content

Commit

Permalink
Remove trailing slash from jPath for self-closing tags (#595)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-radzikowski authored Jun 27, 2023
1 parent 643816d commit 2f2f787
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions spec/updateTag_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ describe("XMLParser updateTag ", function() {
<img width="500" height="500">
</content>
<script></script>
<lorem/>
<ipsum/>
</body>
</html>`;
const expected = {
Expand Down Expand Up @@ -167,6 +169,10 @@ describe("XMLParser updateTag ", function() {
if(attrs.width > 200 || attrs.height > 200) return false;
}else if(tagname === "content"){
return "div"
}else if(tagname === "lorem") {
return false;
}else if(jPath === "html.body.ipsum") {
return false;
}
return tagname;
},
Expand Down
1 change: 1 addition & 0 deletions src/xmlparser/OrderedObjParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ const parseXml = function(xmlData) {
if(tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1){
if(tagName[tagName.length - 1] === "/"){ //remove trailing '/'
tagName = tagName.substr(0, tagName.length - 1);
jPath = jPath.substr(0, jPath.length - 1);
tagExp = tagName;
}else{
tagExp = tagExp.substr(0, tagExp.length - 1);
Expand Down

0 comments on commit 2f2f787

Please sign in to comment.