From ef6a76f685ef658028f1e012d2af2fca55ac8600 Mon Sep 17 00:00:00 2001 From: vcoppe Date: Mon, 15 Jul 2024 21:47:09 +0200 Subject: [PATCH] fix empty metadata tag value parsed as empty string --- gpx/src/io.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gpx/src/io.ts b/gpx/src/io.ts index 20fd6c58..6a7d36f4 100644 --- a/gpx/src/io.ts +++ b/gpx/src/io.ts @@ -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); }