Skip to content

Commit e013bf2

Browse files
committed
fixup! saveguard against without intl and more robust implementation
1 parent d727cf5 commit e013bf2

2 files changed

Lines changed: 34 additions & 13 deletions

File tree

lib/internal/util/inspect.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -704,19 +704,30 @@ function highlightRegExp(regexpString) {
704704
} else if (ch === '|' || ch === '+' || ch === '*' || ch === '?' || ch === ',' || ch === '^' || ch === '$') {
705705
writeDepth(ch, 3, 1);
706706
} else if (ch === '{') {
707-
write('{');
708-
depth++;
709707
i++;
710708
let digits = '';
711709
while (i < regexpString.length && regexpString[i] >= '0' && regexpString[i] <= '9') {
712710
digits += regexpString[i++];
713711
}
714712
if (digits) {
713+
write('{');
714+
depth++;
715715
writeDepth(digits, 1, 0);
716716
}
717-
if (i < regexpString.length && regexpString[i] === ',') {
718-
write(',');
719-
i++;
717+
if (i < regexpString.length) {
718+
if (regexpString[i] === ',') {
719+
if (!digits) {
720+
write('{');
721+
depth++;
722+
}
723+
write(',');
724+
i++;
725+
} else if (!digits) {
726+
depth += 1;
727+
write('{');
728+
depth -= 1;
729+
continue;
730+
}
720731
}
721732
let digits2 = '';
722733
while (i < regexpString.length && regexpString[i] >= '0' && regexpString[i] <= '9') {

test/parallel/test-util-inspect-regexp.js

Lines changed: 18 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)