fix empty metadata tag value parsed as empty string

This commit is contained in:
vcoppe
2024-07-15 21:47:09 +02:00
parent 1d33607266
commit ef6a76f685

View File

@@ -7,7 +7,7 @@ export function parseGPX(gpxData: string): GPXFile {
ignoreAttributes: false,
attributeNamePrefix: "",
attributesGroupName: 'attributes',
isArray: (name: string) => {
isArray(name: string) {
return name === 'trk' || name === 'trkseg' || name === 'trkpt' || name === 'wpt' || name === 'rte' || name === 'rtept' || name === 'gpxx:rpt';
},
attributeValueProcessor(attrName, attrValue, jPath) {
@@ -52,6 +52,11 @@ export function parseGPX(gpxData: string): GPXFile {
const parsed: GPXFileType = parser.parse(gpxData).gpx;
// @ts-ignore
if (parsed.metadata === "") {
parsed.metadata = {};
}
return new GPXFile(parsed);
}