File tree 3 files changed +18
-2
lines changed
3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ module.exports = options => {
6
6
} , options ) ;
7
7
8
8
const 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)' ,
10
10
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
11
11
] . join ( '|' ) ;
12
12
Original file line number Diff line number Diff line change @@ -40,6 +40,9 @@ ansiRegex().test('cake');
40
40
41
41
' \u001B [4mcake\u001B [0m' .match (ansiRegex ({onlyFirst: true }));
42
42
// => ['\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']
43
46
```
44
47
45
48
Original file line number Diff line number Diff line change @@ -41,7 +41,20 @@ test('match only first', t => {
41
41
t . is ( 'foo\u001B[4mcake\u001B[0m' . match ( ansiRegex ( { onlyFirst : true } ) ) . length , 1 ) ;
42
42
} ) ;
43
43
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 => {
45
58
t . 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' ) ;
46
59
} ) ;
47
60
You can’t perform that action at this time.
0 commit comments