File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ module.exports = options => {
66} , options ) ;
77
88const pattern = [
9- '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)' ,
9+ '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[- a-zA-Z\\d\\/#&.:=?%@~_ ]*)*)?\\u0007)' ,
1010'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
1111] . join ( '|' ) ;
1212
Original file line number Diff line number Diff line change @@ -40,6 +40,9 @@ ansiRegex().test('cake');
4040
4141' \u001B [4mcake\u001B [0m' .match (ansiRegex ({onlyFirst: true }));
4242// => ['\u001B[4m']
43+
44+ ' \u001B ]8;;https://github.com\u0007 click\u001B ]8;;\u0007 ' .match (ansiRegex ());
45+ // => ['\u001B]8;;https://github.com\u0007', '\u001B]8;;\u0007']
4346```
4447
4548
Original file line number Diff line number Diff line change @@ -41,7 +41,20 @@ test('match only first', t => {
4141t . is ( 'foo\u001B[4mcake\u001B[0m' . match ( ansiRegex ( { onlyFirst : true } ) ) . length , 1 ) ;
4242} ) ;
4343
44- test . failing ( 'match "change icon name and window title" in string' , t => {
44+ test ( 'match terminal link' , t => {
45+ t . regex ( '\u001B]8;k=v;https://example-a.com/?a_b=1&c=2#tit%20le\u0007click\u001B]8;;\u0007' , ansiRegex ( ) ) ;
46+ t . regex ( '\u001B]8;;mailto:no-replay@mail.com\u0007mail\u001B]8;;\u0007' , ansiRegex ( ) ) ;
47+ t . deepEqual ( '\u001B]8;k=v;https://example-a.com/?a_b=1&c=2#tit%20le\u0007click\u001B]8;;\u0007' . match ( ansiRegex ( ) ) , [
48+ '\u001B]8;k=v;https://example-a.com/?a_b=1&c=2#tit%20le\u0007' ,
49+ '\u001B]8;;\u0007'
50+ ] ) ;
51+ t . deepEqual ( '\u001B]8;;mailto:no-reply@mail.com\u0007mail-me\u001B]8;;\u0007' . match ( ansiRegex ( ) ) , [
52+ '\u001B]8;;mailto:no-reply@mail.com\u0007' ,
53+ '\u001B]8;;\u0007'
54+ ] ) ;
55+ } ) ;
56+
57+ test ( 'match "change icon name and window title" in string' , t => {
4558t . is ( '\u001B]0;sg@tota:~/git/\u0007\u001B[01;32m[sg@tota\u001B[01;37m misc-tests\u001B[01;32m]$' . match ( ansiRegex ( ) ) [ 0 ] , '\u001B]0;sg@tota:~/git/\u0007' ) ;
4659} ) ;
4760
You can’t perform that action at this time.
0 commit comments