fix(jsonl): add explicit UTF-8 BOM stripping

Strip BOM character before JSON parsing to ensure robust
cross-platform JSONL file handling.
This commit is contained in:
kaitranntt committed 2026-02-02 23:40:36 -05:00
1 parent 66f5fe6b2c
commit 09b5239f58
2 files changed
+14 -2

No files matched your search

+10
View File
@@ -133,6 +133,16 @@ describe('parseUsageEntry', () => {
expect(parseUsageEntry('not json at all', '/test')).toBeNull();
});
test('strips UTF-8 BOM from line before parsing', () => {
// UTF-8 BOM character (\uFEFF) can appear at start of files
const bomEntry = '\uFEFF' + VALID_ASSISTANT_ENTRY;
const result = parseUsageEntry(bomEntry, '/test');
expect(result).not.toBeNull();
expect(result!.model).toBe('claude-sonnet-4-5');
expect(result!.inputTokens).toBe(1000);
});
test('includes project path in result', () => {
const result = parseUsageEntry(VALID_ASSISTANT_ENTRY, '/custom/project/path');
expect(result!.projectPath).toBe('/custom/project/path');