From 2c76aed9b928c6fda78fbe057f9636b27dbcc31f Mon Sep 17 00:00:00 2001 From: vangyyy Date: Mon, 15 Sep 2025 18:27:00 +0200 Subject: [PATCH] Fix .gpx.gz decompression --- src/track.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/track.js b/src/track.js index 8650c0b..d9202c2 100644 --- a/src/track.js +++ b/src/track.js @@ -168,13 +168,24 @@ function readFile(file, encoding, isGzipped) { reader.onload = (e) => { const result = e.target.result; try { - return resolve(isGzipped ? Pako.inflate(result) : result); + if (isGzipped) { + const inflated = Pako.inflate(result); + // For text files, convert the Uint8Array back to string + if (encoding === 'text') { + const decoder = new TextDecoder('utf-8'); + return resolve(decoder.decode(inflated)); + } else { + return resolve(inflated); + } + } else { + return resolve(result); + } } catch (e) { return reject(e); } }; - if (encoding === 'binary') { + if (encoding === 'binary' || isGzipped) { reader.readAsArrayBuffer(file); } else { reader.readAsText(file);