source dump of claude code
at main 16 lines 657 B view raw
1/** 2 * Leaf stripBOM — extracted from json.ts to break settings → json → log → 3 * types/logs → … → settings. json.ts imports this for its memoized+logging 4 * safeParseJSON; leaf callers that can't import json.ts use stripBOM + 5 * jsonParse inline (syncCacheState does this). 6 * 7 * UTF-8 BOM (U+FEFF): PowerShell 5.x writes UTF-8 with BOM by default 8 * (Out-File, Set-Content). We can't control user environments, so strip on 9 * read. Without this, JSON.parse fails with "Unexpected token". 10 */ 11 12const UTF8_BOM = '\uFEFF' 13 14export function stripBOM(content: string): string { 15 return content.startsWith(UTF8_BOM) ? content.slice(1) : content 16}