From 98405b78ae2995e6015b173fd1375f4fd83defed Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sat, 25 Sep 2021 11:48:38 -0400 Subject: [PATCH] util: improve ansi escape code regex --- lib/internal/util/inspect.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index a3b7b8677d37d4..b221b084275867 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -222,7 +222,8 @@ const meta = [ // License: MIT, authors: @sindresorhus, Qix-, arjunmehta and LitoMore // Matches all ansi escape code sequences in a string const ansiPattern = '[\\u001B\\u009B][[\\]()#;?]*' + - '(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)' + + '(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*' + + '|[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');