From 5f3f5dfe3950533ac72699b10e5c8662ea43e0fc Mon Sep 17 00:00:00 2001 From: Andrew Patton Date: Mon, 6 May 2024 14:11:47 -0700 Subject: [PATCH] Improve support for premature closing curlies makes new failing test case pass --- packages/parsing/src/parse-as-json.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/parsing/src/parse-as-json.ts b/packages/parsing/src/parse-as-json.ts index 3c088d40..39c25d9b 100644 --- a/packages/parsing/src/parse-as-json.ts +++ b/packages/parsing/src/parse-as-json.ts @@ -382,6 +382,13 @@ export function parseAsJSON(text: string): ParsedValue | null { }); const maybeKey = quoteIndex > index ? text.slice(quoteIndex) : ''; if (OBJECT_KEY_REGEXP.test(maybeKey)) { + // if missing a comma, add it here + if ( + quoteIndex > startIndex && + !text.slice(startIndex, quoteIndex).includes(',') + ) { + newText += ','; + } continue; } }