File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,8 @@ export function getCrossPlatformPathRegex(
1414  opts : {  escape : boolean  }  =  {  escape : true  } , 
1515)  { 
1616  const  newExpr  =  ( 
17-     opts . escape  ? regex . replace ( / ( [ [ \] ( ) . * + ? ^ $ | ] ) / g,  "\\$1" )  : regex 
18-   ) . replaceAll ( "/" ,  " (?:\\ /|\\\\)" ) ; 
17+     opts . escape  ? regex . replace ( / ( [ [ \] ( ) . * + ? ^ $ | { } \\ ] ) / g,  "\\$1" )  : regex 
18+   ) . replaceAll ( "/" ,  String . raw ` (?:\/|\\)` ) ; 
1919
2020  return  new  RegExp ( newExpr ,  "g" ) ; 
2121} 
Original file line number Diff line number Diff line change 11import  {  getCrossPlatformPathRegex  }  from  "@opennextjs/aws/utils/regex.js" ; 
22
3- const  specialChars  =  "^([123]+|[123]*) ?$" ; 
3+ const  specialChars  =  "^([123]+|[123]{1,3})*\\ ?$" ; 
44
55describe ( "getCrossPlatformPathRegex" ,  ( )  =>  { 
66  it ( "should return a regex without escaping characters" ,  ( )  =>  { 
@@ -11,12 +11,14 @@ describe("getCrossPlatformPathRegex", () => {
1111  it ( "should always create cross-platform separators" ,  ( )  =>  { 
1212    [ true ,  false ] . forEach ( ( v )  =>  { 
1313      const  regexp  =  getCrossPlatformPathRegex ( "test/path" ,  {  escape : v  } ) ; 
14-       expect ( regexp . source ) . toEqual ( " test(?:\\ /|\\\\ )path" ) ; 
14+       expect ( regexp . source ) . toEqual ( String . raw ` test(?:\/|\\)path` ) ; 
1515    } ) ; 
1616  } ) ; 
1717
1818  it ( "should return a regex with escaped characters" ,  ( )  =>  { 
1919    const  regexp  =  getCrossPlatformPathRegex ( specialChars ,  {  escape : true  } ) ; 
20-     expect ( regexp . source ) . toEqual ( "\\^\\(\\[123\\]\\+\\|\\[123\\]\\*\\)\\?\\$" ) ; 
20+     expect ( regexp . source ) . toEqual ( 
21+       String . raw `\^\(\[123\]\+\|\[123\]\{1,3\}\)\*\\\?\$` , 
22+     ) ; 
2123  } ) ; 
2224} ) ; 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments