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); }