minimatch 5.1.0 → 5.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/minimatch.js +16 -15
- package/package.json +2 -2
package/minimatch.js
CHANGED
|
@@ -157,7 +157,9 @@ minimatch.match = (list, pattern, options = {}) => {
|
|
|
157
157
|
|
|
158
158
|
// replace stuff like \* with *
|
|
159
159
|
const globUnescape = s => s.replace(/\\(.)/g, '$1')
|
|
160
|
+
const charUnescape = s => s.replace(/\\([^-\]])/g, '$1')
|
|
160
161
|
const regExpEscape = s => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')
|
|
162
|
+
const braExpEscape = s => s.replace(/[[\]\\]/g, '\\$&')
|
|
161
163
|
|
|
162
164
|
class Minimatch {
|
|
163
165
|
constructor (pattern, options) {
|
|
@@ -243,7 +245,7 @@ class Minimatch {
|
|
|
243
245
|
negateOffset++
|
|
244
246
|
}
|
|
245
247
|
|
|
246
|
-
if (negateOffset) this.pattern = pattern.
|
|
248
|
+
if (negateOffset) this.pattern = pattern.slice(negateOffset)
|
|
247
249
|
this.negate = negate
|
|
248
250
|
}
|
|
249
251
|
|
|
@@ -492,6 +494,11 @@ class Minimatch {
|
|
|
492
494
|
}
|
|
493
495
|
|
|
494
496
|
case '\\':
|
|
497
|
+
if (inClass && pattern.charAt(i + 1) === '-') {
|
|
498
|
+
re += c
|
|
499
|
+
continue
|
|
500
|
+
}
|
|
501
|
+
|
|
495
502
|
clearStateChar()
|
|
496
503
|
escaping = true
|
|
497
504
|
continue
|
|
@@ -604,8 +611,6 @@ class Minimatch {
|
|
|
604
611
|
continue
|
|
605
612
|
}
|
|
606
613
|
|
|
607
|
-
// handle the case where we left a class open.
|
|
608
|
-
// "[z-a]" is valid, equivalent to "\[z-a\]"
|
|
609
614
|
// split where the last [ was, make sure we don't have
|
|
610
615
|
// an invalid re. if so, re-walk the contents of the
|
|
611
616
|
// would-be class to re-translate any characters that
|
|
@@ -615,20 +620,16 @@ class Minimatch {
|
|
|
615
620
|
// to do safely. For now, this is safe and works.
|
|
616
621
|
cs = pattern.substring(classStart + 1, i)
|
|
617
622
|
try {
|
|
618
|
-
RegExp('[' + cs + ']')
|
|
623
|
+
RegExp('[' + braExpEscape(charUnescape(cs)) + ']')
|
|
624
|
+
// looks good, finish up the class.
|
|
625
|
+
re += c
|
|
619
626
|
} catch (er) {
|
|
620
|
-
//
|
|
621
|
-
|
|
622
|
-
re = re.
|
|
623
|
-
hasMagic = hasMagic || sp[1]
|
|
624
|
-
inClass = false
|
|
625
|
-
continue
|
|
627
|
+
// out of order ranges in JS are errors, but in glob syntax,
|
|
628
|
+
// they're just a range that matches nothing.
|
|
629
|
+
re = re.substring(0, reClassStart) + '(?:$.)' // match nothing ever
|
|
626
630
|
}
|
|
627
|
-
|
|
628
|
-
// finish up the class.
|
|
629
631
|
hasMagic = true
|
|
630
632
|
inClass = false
|
|
631
|
-
re += c
|
|
632
633
|
continue
|
|
633
634
|
|
|
634
635
|
default:
|
|
@@ -652,9 +653,9 @@ class Minimatch {
|
|
|
652
653
|
// this is a huge pita. We now have to re-walk
|
|
653
654
|
// the contents of the would-be class to re-translate
|
|
654
655
|
// any characters that were passed through as-is
|
|
655
|
-
cs = pattern.
|
|
656
|
+
cs = pattern.slice(classStart + 1)
|
|
656
657
|
sp = this.parse(cs, SUBPARSE)
|
|
657
|
-
re = re.
|
|
658
|
+
re = re.substring(0, reClassStart) + '\\[' + sp[0]
|
|
658
659
|
hasMagic = hasMagic || sp[1]
|
|
659
660
|
}
|
|
660
661
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)",
|
|
3
3
|
"name": "minimatch",
|
|
4
4
|
"description": "a glob matcher in javascript",
|
|
5
|
-
"version": "5.1.
|
|
5
|
+
"version": "5.1.2",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git://github.com/isaacs/minimatch.git"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"brace-expansion": "^2.0.1"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"tap": "^
|
|
25
|
+
"tap": "^16.3.2"
|
|
26
26
|
},
|
|
27
27
|
"license": "ISC",
|
|
28
28
|
"files": [
|