Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/track.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading