fix(imports): tolerate a UTF-8 BOM in uploaded Trakt JSON

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
jakeandClaude Sonnet 5.5 committed 2026-10-04 15:40:23 -04:00
1 parent 2767b495e3
commit 0c9ef44ea4
2 files changed
+19 -2

No files matched your search

+12
View File
@@ -1362,6 +1362,18 @@ describe("parseTraktExport", () => {
);
});
test("accepts a JSON file with a UTF-8 byte-order mark", async () => {
const bytes = new Uint8Array([
0xef,
0xbb,
0xbf,
...new TextEncoder().encode(JSON.stringify(historyItems)),
]);
const result = await parseTraktExport(new Blob([bytes], { type: "application/json" }));
expect(result.data.movies).toHaveLength(1);
expect(result.data.episodes).toHaveLength(1);
});
test("skips an unparsable JSON entry inside the ZIP", async () => {
const zip = createZip({
"watched-history-1.json": JSON.stringify(historyItems),