Skip to content

Commit

Permalink
Add fix for CDATA parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
We-Gold committed Jun 25, 2024
1 parent 78fb656 commit b8d6552
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
20 changes: 9 additions & 11 deletions lib/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,18 @@ export const parseGPXWithCustomParser = (
email:
emailElement !== null
? {
id: emailElement.getAttribute("id") ?? "",
domain:
emailElement.getAttribute("domain") ?? "",
}
id: emailElement.getAttribute("id") ?? "",
domain:
emailElement.getAttribute("domain") ?? "",
}
: null,
link:
linkElement !== null
? {
href: linkElement.getAttribute("href") ?? "",
text: getElementValue(linkElement, "text"),
type: getElementValue(linkElement, "type"),
}
href: linkElement.getAttribute("href") ?? "",
text: getElementValue(linkElement, "text"),
type: getElementValue(linkElement, "type"),
}
: null,
}
}
Expand Down Expand Up @@ -322,9 +322,7 @@ const getElementValue = (parent: Element, tag: string): string => {

// Extract and return the value within the parent element
if (element !== null) {
return element.innerHTML != undefined
? element.innerHTML
: element.childNodes[0].textContent ?? ""
return element.firstChild?.textContent ?? element.innerHTML ?? ""
} else return ""
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@we-gold/gpxjs",
"author": "Weaver Goldman <[email protected]>",
"description": "GPX.js is a modern library for parsing GPX files and converting them to GeoJSON.",
"version": "1.0.9",
"version": "1.0.10",
"type": "module",
"license": "MIT",
"repository": {
Expand Down

0 comments on commit b8d6552

Please sign in to comment.