Skip to content

Commit 424c37b

Browse files
BridgeARMylesBorins
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 8b92223 commit 424c37b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/internal/readline/utils.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ const {
77

88
// Regex used for ansi escape code splitting
99
// Adopted from https://github.com/chalk/ansi-regex/blob/master/index.js
10-
// License: MIT, authors: @sindresorhus, Qix-, and arjunmehta
10+
// License: MIT, authors: @sindresorhus, Qix-, arjunmehta and LitoMore
1111
// 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 */
12+
const ansiPattern = '[\\u001B\\u009B][[\\]()#;?]*' +
13+
'(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)' +
14+
'|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))';
15+
const ansi = new RegExp(ansiPattern, 'g');
16+
1617
const kUTF16SurrogateThreshold = 0x10000; // 2 ** 16
1718
const kEscape = '\x1b';
1819

0 commit comments

Comments
 (0)