Skip to content

Commit 0bafe08

Browse files
BridgeARtargos
authored andcommitted
readline: update ansi-regex
This updates the used regular expression to the latest version. It includes a number of additional escape codes. PR-URL: #30907 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 6188650 commit 0bafe08

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/internal/readline/utils.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@
33
const {
44
Boolean,
55
NumberIsInteger,
6+
RegExp,
67
} = primordials;
78

89
// Regex used for ansi escape code splitting
910
// Adopted from https://github.com/chalk/ansi-regex/blob/master/index.js
10-
// License: MIT, authors: @sindresorhus, Qix-, and arjunmehta
11+
// License: MIT, authors: @sindresorhus, Qix-, arjunmehta and LitoMore
1112
// Matches all ansi escape code sequences in a string
12-
/* eslint-disable no-control-regex */
13-
const ansi =
14-
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
15-
/* eslint-enable no-control-regex */
13+
const ansiPattern = '[\\u001B\\u009B][[\\]()#;?]*' +
14+
'(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)' +
15+
'|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))';
16+
const ansi = new RegExp(ansiPattern, 'g');
17+
1618
const kUTF16SurrogateThreshold = 0x10000; // 2 ** 16
1719
const kEscape = '\x1b';
1820

0 commit comments

Comments
 (0)