@@ -56,7 +56,6 @@ function filter (pattern, options) {
56
56
}
57
57
58
58
function ext ( a , b ) {
59
- a = a || { }
60
59
b = b || { }
61
60
const t = { }
62
61
Object . keys ( a ) . forEach ( function ( k ) {
@@ -123,9 +122,6 @@ function minimatch (p, pattern, options) {
123
122
return false
124
123
}
125
124
126
- // "" only matches ""
127
- if ( pattern . trim ( ) === '' ) return p === ''
128
-
129
125
return new Minimatch ( pattern , options ) . match ( p )
130
126
}
131
127
@@ -137,7 +133,6 @@ function Minimatch (pattern, options) {
137
133
assertValidPattern ( pattern )
138
134
139
135
if ( ! options ) options = { }
140
- pattern = pattern . trim ( )
141
136
142
137
// windows support: need to use /, not \
143
138
if ( path . sep !== '/' ) {
@@ -160,9 +155,6 @@ Minimatch.prototype.debug = function () {}
160
155
161
156
Minimatch . prototype . make = make
162
157
function make ( ) {
163
- // don't do it more than once.
164
- if ( this . _made ) return
165
-
166
158
var pattern = this . pattern
167
159
var options = this . options
168
160
@@ -182,7 +174,7 @@ function make () {
182
174
// step 2: expand braces
183
175
var set = this . globSet = this . braceExpand ( )
184
176
185
- if ( options . debug ) this . debug = console . error
177
+ if ( options . debug ) this . debug = ( ... args ) => console . error ( ... args )
186
178
187
179
this . debug ( this . pattern , set )
188
180
@@ -304,7 +296,12 @@ function parse (pattern, isSub) {
304
296
var options = this . options
305
297
306
298
// shortcuts
307
- if ( ! options . noglobstar && pattern === '**' ) return GLOBSTAR
299
+ if ( pattern === '**' ) {
300
+ if ( ! options . noglobstar )
301
+ return GLOBSTAR
302
+ else
303
+ pattern = '*'
304
+ }
308
305
if ( pattern === '' ) return ''
309
306
310
307
var re = ''
@@ -360,7 +357,8 @@ function parse (pattern, isSub) {
360
357
}
361
358
362
359
switch ( c ) {
363
- case '/' : /* istanbul ignore next */ {
360
+ /* istanbul ignore next */
361
+ case '/' : {
364
362
// completely not allowed, even escaped.
365
363
// Should already be path-split by now.
366
364
return false
@@ -483,25 +481,23 @@ function parse (pattern, isSub) {
483
481
484
482
// handle the case where we left a class open.
485
483
// "[z-a]" is valid, equivalent to "\[z-a\]"
486
- if ( inClass ) {
487
- // split where the last [ was, make sure we don't have
488
- // an invalid re. if so, re-walk the contents of the
489
- // would-be class to re-translate any characters that
490
- // were passed through as-is
491
- // TODO: It would probably be faster to determine this
492
- // without a try/catch and a new RegExp, but it's tricky
493
- // to do safely. For now, this is safe and works.
494
- var cs = pattern . substring ( classStart + 1 , i )
495
- try {
496
- RegExp ( '[' + cs + ']' )
497
- } catch ( er ) {
498
- // not a valid class!
499
- var sp = this . parse ( cs , SUBPARSE )
500
- re = re . substr ( 0 , reClassStart ) + '\\[' + sp [ 0 ] + '\\]'
501
- hasMagic = hasMagic || sp [ 1 ]
502
- inClass = false
503
- continue
504
- }
484
+ // split where the last [ was, make sure we don't have
485
+ // an invalid re. if so, re-walk the contents of the
486
+ // would-be class to re-translate any characters that
487
+ // were passed through as-is
488
+ // TODO: It would probably be faster to determine this
489
+ // without a try/catch and a new RegExp, but it's tricky
490
+ // to do safely. For now, this is safe and works.
491
+ var cs = pattern . substring ( classStart + 1 , i )
492
+ try {
493
+ RegExp ( '[' + cs + ']' )
494
+ } catch ( er ) {
495
+ // not a valid class!
496
+ var sp = this . parse ( cs , SUBPARSE )
497
+ re = re . substr ( 0 , reClassStart ) + '\\[' + sp [ 0 ] + '\\]'
498
+ hasMagic = hasMagic || sp [ 1 ]
499
+ inClass = false
500
+ continue
505
501
}
506
502
507
503
// finish up the class.
@@ -585,9 +581,7 @@ function parse (pattern, isSub) {
585
581
// something that could conceivably capture a dot
586
582
var addPatternStart = false
587
583
switch ( re . charAt ( 0 ) ) {
588
- case '.' :
589
- case '[' :
590
- case '(' : addPatternStart = true
584
+ case '[' : case '.' : case '(' : addPatternStart = true
591
585
}
592
586
593
587
// Hack to work around lack of negative lookbehind in JS
@@ -725,16 +719,13 @@ minimatch.match = function (list, pattern, options) {
725
719
return list
726
720
}
727
721
728
- Minimatch . prototype . match = match
729
- function match ( f , partial ) {
722
+ Minimatch . prototype . match = function match ( f ) {
730
723
this . debug ( 'match' , f , this . pattern )
731
724
// short-circuit in the case of busted things.
732
725
// comments, etc.
733
726
if ( this . comment ) return false
734
727
if ( this . empty ) return f === ''
735
728
736
- if ( f === '/' && partial ) return true
737
-
738
729
var options = this . options
739
730
740
731
// windows: need to use /, not \
@@ -768,7 +759,7 @@ function match (f, partial) {
768
759
if ( options . matchBase && pattern . length === 1 ) {
769
760
file = [ filename ]
770
761
}
771
- var hit = this . matchOne ( file , pattern , partial )
762
+ var hit = this . matchOne ( file , pattern , false )
772
763
if ( hit ) {
773
764
if ( options . flipNegate ) return true
774
765
return ! this . negate
0 commit comments