@@ -12,7 +12,7 @@ export const minimatch = (p, pattern, options = {}) => {
1212 return new Minimatch ( pattern , options ) . match ( p ) ;
1313} ;
1414// Optimized checking for the most common glob patterns.
15- const starDotExtRE = / ^ \* + ( [ ^ + @ ! ? \* \[ \ (] * ) $ / ;
15+ const starDotExtRE = / ^ \* + ( [ ^ + @ ! ? * [ ( ] * ) $ / ;
1616const starDotExtTest = ( ext ) => ( f ) => ! f . startsWith ( '.' ) && f . endsWith ( ext ) ;
1717const starDotExtTestDot = ( ext ) => ( f ) => f . endsWith ( ext ) ;
1818const starDotExtTestNocase = ( ext ) => {
@@ -31,7 +31,7 @@ const dotStarTest = (f) => f !== '.' && f !== '..' && f.startsWith('.');
3131const starRE = / ^ \* + $ / ;
3232const starTest = ( f ) => f . length !== 0 && ! f . startsWith ( '.' ) ;
3333const starTestDot = ( f ) => f . length !== 0 && f !== '.' && f !== '..' ;
34- const qmarksRE = / ^ \? + ( [ ^ + @ ! ? \* \[ \ (] * ) ? $ / ;
34+ const qmarksRE = / ^ \? + ( [ ^ + @ ! ? * [ ( ] * ) ? $ / ;
3535const qmarksTestNocase = ( [ $0 , ext = '' ] ) => {
3636 const noext = qmarksTestNoExt ( [ $0 ] ) ;
3737 if ( ! ext )
@@ -258,6 +258,7 @@ export class Minimatch {
258258 // step 2: expand braces
259259 this . globSet = [ ...new Set ( this . braceExpand ( ) ) ] ;
260260 if ( options . debug ) {
261+ //oxlint-disable-next-line no-console
261262 this . debug = ( ...args ) => console . error ( ...args ) ;
262263 }
263264 this . debug ( this . pattern , this . globSet ) ;
@@ -320,10 +321,10 @@ export class Minimatch {
320321 preprocess ( globParts ) {
321322 // if we're not in globstar mode, then turn ** into *
322323 if ( this . options . noglobstar ) {
323- for ( let i = 0 ; i < globParts . length ; i ++ ) {
324- for ( let j = 0 ; j < globParts [ i ] . length ; j ++ ) {
325- if ( globParts [ i ] [ j ] === '**' ) {
326- globParts [ i ] [ j ] = '*' ;
324+ for ( const partset of globParts ) {
325+ for ( let j = 0 ; j < partset . length ; j ++ ) {
326+ if ( partset [ j ] === '**' ) {
327+ partset [ j ] = '*' ;
327328 }
328329 }
329330 }
@@ -411,7 +412,11 @@ export class Minimatch {
411412 let dd = 0 ;
412413 while ( - 1 !== ( dd = parts . indexOf ( '..' , dd + 1 ) ) ) {
413414 const p = parts [ dd - 1 ] ;
414- if ( p && p !== '.' && p !== '..' && p !== '**' ) {
415+ if ( p &&
416+ p !== '.' &&
417+ p !== '..' &&
418+ p !== '**' &&
419+ ! ( this . isWindows && / ^ [ a - z ] : $ / i. test ( p ) ) ) {
415420 didSomething = true ;
416421 parts . splice ( dd - 1 , 2 ) ;
417422 dd -= 2 ;
@@ -660,15 +665,17 @@ export class Minimatch {
660665 // split the pattern up into globstar-delimited sections
661666 // the tail has to be at the end, and the others just have
662667 // to be found in order from the head.
663- const [ head , body , tail ] = partial ? [
664- pattern . slice ( patternIndex , firstgs ) ,
665- pattern . slice ( firstgs + 1 ) ,
666- [ ] ,
667- ] : [
668- pattern . slice ( patternIndex , firstgs ) ,
669- pattern . slice ( firstgs + 1 , lastgs ) ,
670- pattern . slice ( lastgs + 1 ) ,
671- ] ;
668+ const [ head , body , tail ] = partial ?
669+ [
670+ pattern . slice ( patternIndex , firstgs ) ,
671+ pattern . slice ( firstgs + 1 ) ,
672+ [ ] ,
673+ ]
674+ : [
675+ pattern . slice ( patternIndex , firstgs ) ,
676+ pattern . slice ( firstgs + 1 , lastgs ) ,
677+ pattern . slice ( lastgs + 1 ) ,
678+ ] ;
672679 // check the head, from the current file/pattern index.
673680 if ( head . length ) {
674681 const fileHead = file . slice ( fileIndex , fileIndex + head . length ) ;
@@ -1014,7 +1021,7 @@ export class Minimatch {
10141021 this . regexp = new RegExp ( re , [ ...flags ] . join ( '' ) ) ;
10151022 /* c8 ignore start */
10161023 }
1017- catch ( ex ) {
1024+ catch {
10181025 // should be impossible
10191026 this . regexp = false ;
10201027 }
@@ -1029,7 +1036,7 @@ export class Minimatch {
10291036 if ( this . preserveMultipleSlashes ) {
10301037 return p . split ( '/' ) ;
10311038 }
1032- else if ( this . isWindows && / ^ \/ \/ [ ^ \ /] + / . test ( p ) ) {
1039+ else if ( this . isWindows && / ^ \/ \/ [ ^ / ] + / . test ( p ) ) {
10331040 // add an extra '' for the one we lose
10341041 return [ '' , ...p . split ( / \/ + / ) ] ;
10351042 }
@@ -1071,8 +1078,7 @@ export class Minimatch {
10711078 filename = ff [ i ] ;
10721079 }
10731080 }
1074- for ( let i = 0 ; i < set . length ; i ++ ) {
1075- const pattern = set [ i ] ;
1081+ for ( const pattern of set ) {
10761082 let file = ff ;
10771083 if ( options . matchBase && pattern . length === 1 ) {
10781084 file = [ filename ] ;
0 commit comments