Skip to content

Commit

Permalink
Improve support for premature closing curlies
Browse files Browse the repository at this point in the history
makes new failing test case pass
  • Loading branch information
acusti committed May 6, 2024
1 parent 04a5197 commit 5f3f5df
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/parsing/src/parse-as-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 5f3f5df

Please sign in to comment.