Skip to content

Commit 726c3a1

Browse files
committed
Address comments
1 parent 0bf6778 commit 726c3a1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/utils.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,13 +344,16 @@ function parseJSONWithBigInt(str) {
344344
// For older Node.js versions, preprocess the JSON string to convert
345345
// large integers (outside the safe integer range) to strings before parsing.
346346
// This replaces the functionality of json-bigint package.
347+
// The regex matches integers after: colon (:), comma (,), or open bracket ([)
347348
const processed = str.replace(
348-
/:\s*(-?\d+)(?=\s*[,}\]])/g,
349+
/(?:[:,\[])\s*(-?\d+)(?=\s*[,}\]])/g,
349350
(match, number) => {
350351
const num = Number(number);
351352
// If the number is not safe, keep it as a string
352353
if (!Number.isSafeInteger(num)) {
353-
return `: "${number}"`;
354+
// Preserve the prefix character (: or , or [)
355+
const prefix = match.charAt(0);
356+
return `${prefix} "${number}"`;
354357
}
355358
return match;
356359
}

0 commit comments

Comments
 (0)