Skip to content

Commit bacd1a7

Browse files
committed
fixup! util: add fast path to stripVTControlCharacters
1 parent 003511d commit bacd1a7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/internal/util/inspect.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3036,6 +3036,9 @@ if (internalBinding('config').hasIntl) {
30363036
function stripVTControlCharacters(str) {
30373037
validateString(str, 'str');
30383038

3039+
// Short-circuit: all ANSI escape sequences start with either
3040+
// ESC (\u001B, 7-bit) or CSI (\u009B, 8-bit) introducer.
3041+
// If neither is present, the string has no VT control characters.
30393042
if (!StringPrototypeIncludes(str, '\u001B') &&
30403043
!StringPrototypeIncludes(str, '\u009B'))
30413044
return str;

0 commit comments

Comments
 (0)