minimatch 5.1.1 → 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 +13 -12
- package/package.json +1 -1
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) {
|
|
@@ -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.substring(0, reClassStart) + '
|
|
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:
|
package/package.json
CHANGED