Skip to content

Commit b8d6552

Browse files
committed
Add fix for CDATA parsing.
1 parent 78fb656 commit b8d6552

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

lib/parse.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,18 @@ export const parseGPXWithCustomParser = (
8282
email:
8383
emailElement !== null
8484
? {
85-
id: emailElement.getAttribute("id") ?? "",
86-
domain:
87-
emailElement.getAttribute("domain") ?? "",
88-
}
85+
id: emailElement.getAttribute("id") ?? "",
86+
domain:
87+
emailElement.getAttribute("domain") ?? "",
88+
}
8989
: null,
9090
link:
9191
linkElement !== null
9292
? {
93-
href: linkElement.getAttribute("href") ?? "",
94-
text: getElementValue(linkElement, "text"),
95-
type: getElementValue(linkElement, "type"),
96-
}
93+
href: linkElement.getAttribute("href") ?? "",
94+
text: getElementValue(linkElement, "text"),
95+
type: getElementValue(linkElement, "type"),
96+
}
9797
: null,
9898
}
9999
}
@@ -322,9 +322,7 @@ const getElementValue = (parent: Element, tag: string): string => {
322322

323323
// Extract and return the value within the parent element
324324
if (element !== null) {
325-
return element.innerHTML != undefined
326-
? element.innerHTML
327-
: element.childNodes[0].textContent ?? ""
325+
return element.firstChild?.textContent ?? element.innerHTML ?? ""
328326
} else return ""
329327
}
330328

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@we-gold/gpxjs",
33
"author": "Weaver Goldman <we.goldm@gmail.com>",
44
"description": "GPX.js is a modern library for parsing GPX files and converting them to GeoJSON.",
5-
"version": "1.0.9",
5+
"version": "1.0.10",
66
"type": "module",
77
"license": "MIT",
88
"repository": {

0 commit comments

Comments
 (0)