diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-12-11 13:12:26 +0300 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-12-15 18:23:59 +0300 |
commit | 8f9cd3841d3fe52f7cb9a6dbd3f65e7ddec13e8b (patch) | |
tree | 6053d39d588490979f934af74a0042c170559221 /lib/internal/readline | |
parent | 1aab392cf3b40ce9be78cd2c2019e51e01141064 (diff) |
readline: update ansi-regex
This updates the used regular expression to the latest version.
It includes a number of additional escape codes.
PR-URL: https://github.com/nodejs/node/pull/30907
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'lib/internal/readline')
-rw-r--r-- | lib/internal/readline/utils.js | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/internal/readline/utils.js b/lib/internal/readline/utils.js index 510acf22183..084976f440d 100644 --- a/lib/internal/readline/utils.js +++ b/lib/internal/readline/utils.js @@ -7,12 +7,13 @@ const { // Regex used for ansi escape code splitting // Adopted from https://github.com/chalk/ansi-regex/blob/master/index.js -// License: MIT, authors: @sindresorhus, Qix-, and arjunmehta +// License: MIT, authors: @sindresorhus, Qix-, arjunmehta and LitoMore // Matches all ansi escape code sequences in a string -/* eslint-disable no-control-regex */ -const ansi = - /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g; -/* eslint-enable no-control-regex */ +const ansiPattern = '[\\u001B\\u009B][[\\]()#;?]*' + + '(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)' + + '|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'; +const ansi = new RegExp(ansiPattern, 'g'); + const kUTF16SurrogateThreshold = 0x10000; // 2 ** 16 const kEscape = '\x1b'; |