fix(setup): accept leading BOM in JSON client configs

This commit is contained in:
Kaoru0822
2026-10-06 03:40:42 -07:00
parent af48fe8791
commit fe843ec0b1
3 changed files with 238 additions and 1 deletions
@@ -66,7 +66,9 @@ const parseDocument = (
): Record<string, unknown> => {
if (format === "toml") return objectSchema.parse(parseToml(text));
const errors: ParseError[] = [];
const document = parseJsonc(text, errors, { allowTrailingComma: true });
// Accept a UTF-8 BOM without shifting diagnostics or editing the original text.
const jsonText = text.startsWith("\uFEFF") ? ` ${text.slice(1)}` : text;
const document = parseJsonc(jsonText, errors, { allowTrailingComma: true });
const firstError = errors[0];
if (firstError !== undefined)
throw new SyntaxError(