mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-14 18:18:21 +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
@@ -70,10 +70,12 @@ export interface ParserOptions {
|
||||
* Returns null for non-assistant entries or entries without usage data
|
||||
*/
|
||||
export function parseUsageEntry(line: string, projectPath: string): RawUsageEntry | null {
|
||||
if (!line.trim()) return null;
|
||||
// Strip UTF-8 BOM if present (can occur on first line of some files)
|
||||
const cleanLine = line.replace(/^\uFEFF/, '').trim();
|
||||
if (!cleanLine) return null;
|
||||
|
||||
try {
|
||||
const entry = JSON.parse(line);
|
||||
const entry = JSON.parse(cleanLine);
|
||||
|
||||
// Only process assistant entries with usage data
|
||||
if (entry.type !== 'assistant') return null;
|
||||
|
||||
Reference in new issue
Block a user