mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-19 14:15:27 +00:00
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:
1 parent
66f5fe6b2c
commit
09b5239f58
2 files changed
+14
-2
No files matched your search
@@ -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');
|
||||
|
||||
Reference in new issue
Block a user