minimatch 3.0.2 → 3.0.3

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.
Files changed (2) hide show
  1. package/minimatch.js +19 -20
  2. package/package.json +1 -1
package/minimatch.js CHANGED
@@ -9,6 +9,14 @@ try {
9
9
  var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
10
10
  var expand = require('brace-expansion')
11
11
 
12
+ var plTypes = {
13
+ '!': { open: '(?:(?!(?:', close: '))[^/]*?)'},
14
+ '?': { open: '(?:', close: ')?' },
15
+ '+': { open: '(?:', close: ')+' },
16
+ '*': { open: '(?:', close: ')*' },
17
+ '@': { open: '(?:', close: ')' }
18
+ }
19
+
12
20
  // any single thing other than /
13
21
  // don't need to escape / when using new RegExp()
14
22
  var qmark = '[^/]'
@@ -277,7 +285,6 @@ function parse (pattern, isSub) {
277
285
  // ? => one single character
278
286
  var patternListStack = []
279
287
  var negativeLists = []
280
- var plType
281
288
  var stateChar
282
289
  var inClass = false
283
290
  var reClassStart = -1
@@ -376,11 +383,12 @@ function parse (pattern, isSub) {
376
383
  continue
377
384
  }
378
385
 
379
- plType = stateChar
380
386
  patternListStack.push({
381
- type: plType,
387
+ type: stateChar,
382
388
  start: i - 1,
383
- reStart: re.length
389
+ reStart: re.length,
390
+ open: plTypes[stateChar].open,
391
+ close: plTypes[stateChar].close
384
392
  })
385
393
  // negation is (?:(?!js)[^/]*)
386
394
  re += stateChar === '!' ? '(?:(?!(?:' : '(?:'
@@ -396,24 +404,14 @@ function parse (pattern, isSub) {
396
404
 
397
405
  clearStateChar()
398
406
  hasMagic = true
399
- re += ')'
400
407
  var pl = patternListStack.pop()
401
- plType = pl.type
402
408
  // negation is (?:(?!js)[^/]*)
403
409
  // The others are (?:<pattern>)<type>
404
- switch (plType) {
405
- case '!':
406
- negativeLists.push(pl)
407
- re += ')[^/]*?)'
408
- pl.reEnd = re.length
409
- break
410
- case '?':
411
- case '+':
412
- case '*':
413
- re += plType
414
- break
415
- case '@': break // the default anyway
410
+ re += pl.close
411
+ if (pl.type === '!') {
412
+ negativeLists.push(pl)
416
413
  }
414
+ pl.reEnd = re.length
417
415
  continue
418
416
 
419
417
  case '|':
@@ -520,7 +518,8 @@ function parse (pattern, isSub) {
520
518
  // Go through and escape them, taking care not to double-escape any
521
519
  // | chars that were already escaped.
522
520
  for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
523
- var tail = re.slice(pl.reStart + 3)
521
+ var tail = re.slice(pl.reStart + pl.open.length)
522
+ this.debug('setting tail', re, pl)
524
523
  // maybe some even number of \, then maybe 1 \, followed by a |
525
524
  tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) {
526
525
  if (!$2) {
@@ -537,7 +536,7 @@ function parse (pattern, isSub) {
537
536
  return $1 + $1 + $2 + '|'
538
537
  })
539
538
 
540
- this.debug('tail=%j\n %s', tail, tail)
539
+ this.debug('tail=%j\n %s', tail, tail, pl, re)
541
540
  var t = pl.type === '*' ? star
542
541
  : pl.type === '?' ? qmark
543
542
  : '\\' + pl.type
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": "3.0.2",
5
+ "version": "3.0.3",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git://github.com/isaacs/minimatch.git"