File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ export default function ansiRegex({onlyFirst = false} = {}) {
33	const  ST  =  '(?:\\u0007|\\u001B\\u005C|\\u009C)' ; 
44	const  pattern  =  [ 
55		`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ ST }  )` , 
6- 		'(?:(?:\\d{1,4}(?:; \\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))' , 
6+ 		'(?:(?:\\d{1,4}(?:[;:] \\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))' , 
77	] . join ( '|' ) ; 
88
99	return  new  RegExp ( pattern ,  onlyFirst  ? undefined  : 'g' ) ; 
Original file line number Diff line number Diff line change @@ -61,6 +61,11 @@ test('match "change icon name and window title" in string', t => {
6161	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' ) ; 
6262} ) ; 
6363
64+ test ( 'match colon separated sequence arguments' ,  t  =>  { 
65+ 	t . regex ( '\u001B[38:2:68:68:68:48:2:0:0:0m' ,  ansiRegex ( ) ) ; 
66+ 	t . is ( '\u001B[38:2:68:68:68:48:2:0:0:0m' . match ( ansiRegex ( ) ) [ 0 ] ,  '\u001B[38:2:68:68:68:48:2:0:0:0m' ) ; 
67+ } ) ; 
68+ 
6469// Testing against extended codes (excluding codes ending in 0-9) 
6570for  ( const  [ codeSetKey ,  codeSetValue ]  of  Object . entries ( ansiCodes ) )  { 
6671	for  ( const  [ code ,  codeInfo ]  of  codeSetValue )  { 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments