minimatch
Advanced tools
Comparing version 6.1.2 to 6.1.3
@@ -475,9 +475,16 @@ "use strict"; | ||
// . and .. never match anything that doesn't start with ., | ||
// even when options.dot is set. | ||
const patternStart = pattern.charAt(0) === '.' | ||
? '' // anything | ||
: // not (start or / followed by . or .. followed by / or end) | ||
options.dot | ||
? '(?!(?:^|\\/)\\.{1,2}(?:$|\\/))' | ||
: '(?!\\.)'; | ||
// even when options.dot is set. However, if the pattern | ||
// starts with ., then traversal patterns can match. | ||
let dotTravAllowed = pattern.charAt(0) === '.'; | ||
let dotFileAllowed = options.dot || dotTravAllowed; | ||
const patternStart = () => dotTravAllowed | ||
? '' | ||
: dotFileAllowed | ||
? '(?!(?:^|\\/)\\.{1,2}(?:$|\\/))' | ||
: '(?!\\.)'; | ||
const subPatternStart = (p) => p.charAt(0) === '.' | ||
? '' | ||
: options.dot | ||
? '(?!(?:^|\\/)\\.{1,2}(?:$|\\/))' | ||
: '(?!\\.)'; | ||
const clearStateChar = () => { | ||
@@ -566,3 +573,3 @@ if (stateChar) { | ||
continue; | ||
case '(': | ||
case '(': { | ||
if (inClass) { | ||
@@ -576,3 +583,3 @@ re += '('; | ||
} | ||
patternListStack.push({ | ||
const plEntry = { | ||
type: stateChar, | ||
@@ -583,16 +590,26 @@ start: i - 1, | ||
close: plTypes[stateChar].close, | ||
}); | ||
// negation is (?:(?!js)[^/]*) | ||
re += stateChar === '!' ? '(?:(?!(?:' : '(?:'; | ||
}; | ||
this.debug(this.pattern, '\t', plEntry); | ||
patternListStack.push(plEntry); | ||
// negation is (?:(?!(?:js)(?:<rest>))[^/]*) | ||
re += plEntry.open; | ||
// next entry starts with a dot maybe? | ||
if (plEntry.start === 0 && plEntry.type !== '!') { | ||
dotTravAllowed = true; | ||
re += subPatternStart(pattern.slice(i + 1)); | ||
} | ||
this.debug('plType %j %j', stateChar, re); | ||
stateChar = false; | ||
continue; | ||
case ')': | ||
if (inClass || !patternListStack.length) { | ||
} | ||
case ')': { | ||
const plEntry = patternListStack.pop(); | ||
if (inClass || !plEntry) { | ||
re += '\\)'; | ||
continue; | ||
} | ||
// closing an extglob | ||
clearStateChar(); | ||
hasMagic = true; | ||
pl = patternListStack.pop(); | ||
pl = plEntry; | ||
// negation is (?:(?!js)[^/]*) | ||
@@ -605,4 +622,6 @@ // The others are (?:<pattern>)<type> | ||
continue; | ||
case '|': | ||
if (inClass || !patternListStack.length) { | ||
} | ||
case '|': { | ||
const plEntry = patternListStack[patternListStack.length - 1]; | ||
if (inClass || !plEntry) { | ||
re += '\\|'; | ||
@@ -613,3 +632,9 @@ continue; | ||
re += '|'; | ||
// next subpattern can start with a dot? | ||
if (plEntry.start === 0 && plEntry.type !== '!') { | ||
dotTravAllowed = true; | ||
re += subPatternStart(pattern.slice(i + 1)); | ||
} | ||
continue; | ||
} | ||
// these are mostly the same in regexp and glob | ||
@@ -689,3 +714,3 @@ case '[': | ||
tail = re.slice(pl.reStart + pl.open.length); | ||
this.debug('setting tail', re, pl); | ||
this.debug(this.pattern, 'setting tail', re, pl); | ||
// maybe some even number of \, then maybe 1 \, followed by a | | ||
@@ -753,3 +778,3 @@ tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, (_, $1, $2) => { | ||
if (addPatternStart) { | ||
re = patternStart + re; | ||
re = patternStart() + re; | ||
} | ||
@@ -756,0 +781,0 @@ // parsing just a piece of a larger pattern. |
@@ -463,9 +463,16 @@ export const minimatch = (p, pattern, options = {}) => { | ||
// . and .. never match anything that doesn't start with ., | ||
// even when options.dot is set. | ||
const patternStart = pattern.charAt(0) === '.' | ||
? '' // anything | ||
: // not (start or / followed by . or .. followed by / or end) | ||
options.dot | ||
? '(?!(?:^|\\/)\\.{1,2}(?:$|\\/))' | ||
: '(?!\\.)'; | ||
// even when options.dot is set. However, if the pattern | ||
// starts with ., then traversal patterns can match. | ||
let dotTravAllowed = pattern.charAt(0) === '.'; | ||
let dotFileAllowed = options.dot || dotTravAllowed; | ||
const patternStart = () => dotTravAllowed | ||
? '' | ||
: dotFileAllowed | ||
? '(?!(?:^|\\/)\\.{1,2}(?:$|\\/))' | ||
: '(?!\\.)'; | ||
const subPatternStart = (p) => p.charAt(0) === '.' | ||
? '' | ||
: options.dot | ||
? '(?!(?:^|\\/)\\.{1,2}(?:$|\\/))' | ||
: '(?!\\.)'; | ||
const clearStateChar = () => { | ||
@@ -554,3 +561,3 @@ if (stateChar) { | ||
continue; | ||
case '(': | ||
case '(': { | ||
if (inClass) { | ||
@@ -564,3 +571,3 @@ re += '('; | ||
} | ||
patternListStack.push({ | ||
const plEntry = { | ||
type: stateChar, | ||
@@ -571,16 +578,26 @@ start: i - 1, | ||
close: plTypes[stateChar].close, | ||
}); | ||
// negation is (?:(?!js)[^/]*) | ||
re += stateChar === '!' ? '(?:(?!(?:' : '(?:'; | ||
}; | ||
this.debug(this.pattern, '\t', plEntry); | ||
patternListStack.push(plEntry); | ||
// negation is (?:(?!(?:js)(?:<rest>))[^/]*) | ||
re += plEntry.open; | ||
// next entry starts with a dot maybe? | ||
if (plEntry.start === 0 && plEntry.type !== '!') { | ||
dotTravAllowed = true; | ||
re += subPatternStart(pattern.slice(i + 1)); | ||
} | ||
this.debug('plType %j %j', stateChar, re); | ||
stateChar = false; | ||
continue; | ||
case ')': | ||
if (inClass || !patternListStack.length) { | ||
} | ||
case ')': { | ||
const plEntry = patternListStack.pop(); | ||
if (inClass || !plEntry) { | ||
re += '\\)'; | ||
continue; | ||
} | ||
// closing an extglob | ||
clearStateChar(); | ||
hasMagic = true; | ||
pl = patternListStack.pop(); | ||
pl = plEntry; | ||
// negation is (?:(?!js)[^/]*) | ||
@@ -593,4 +610,6 @@ // The others are (?:<pattern>)<type> | ||
continue; | ||
case '|': | ||
if (inClass || !patternListStack.length) { | ||
} | ||
case '|': { | ||
const plEntry = patternListStack[patternListStack.length - 1]; | ||
if (inClass || !plEntry) { | ||
re += '\\|'; | ||
@@ -601,3 +620,9 @@ continue; | ||
re += '|'; | ||
// next subpattern can start with a dot? | ||
if (plEntry.start === 0 && plEntry.type !== '!') { | ||
dotTravAllowed = true; | ||
re += subPatternStart(pattern.slice(i + 1)); | ||
} | ||
continue; | ||
} | ||
// these are mostly the same in regexp and glob | ||
@@ -677,3 +702,3 @@ case '[': | ||
tail = re.slice(pl.reStart + pl.open.length); | ||
this.debug('setting tail', re, pl); | ||
this.debug(this.pattern, 'setting tail', re, pl); | ||
// maybe some even number of \, then maybe 1 \, followed by a | | ||
@@ -741,3 +766,3 @@ tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, (_, $1, $2) => { | ||
if (addPatternStart) { | ||
re = patternStart + re; | ||
re = patternStart() + re; | ||
} | ||
@@ -744,0 +769,0 @@ // parsing just a piece of a larger pattern. |
@@ -5,3 +5,3 @@ { | ||
"description": "a glob matcher in javascript", | ||
"version": "6.1.2", | ||
"version": "6.1.3", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
@@ -63,12 +63,12 @@ # minimatch | ||
- Patterns starting with a double-slash followed by some | ||
non-slash characters will preserve their double-slash. As a | ||
non-slash characters will preserve their double-slash. As a | ||
result, a pattern like `//*` will match `//x`, but not `/x`. | ||
- Patterns staring with `//?/<drive letter>:` will *not* treat | ||
the `?` as a wildcard character. Instead, it will be treated | ||
- Patterns staring with `//?/<drive letter>:` will _not_ treat | ||
the `?` as a wildcard character. Instead, it will be treated | ||
as a normal string. | ||
- Patterns starting with `//?/<drive letter>:/...` will match | ||
file paths starting with `<drive letter>:/...`, and vice versa, | ||
as if the `//?/` was not present. This behavior only is | ||
as if the `//?/` was not present. This behavior only is | ||
present when the drive letters are a case-insensitive match to | ||
one another. The remaining portions of the path/pattern are | ||
one another. The remaining portions of the path/pattern are | ||
compared case sensitively, unless `nocase:true` is set. | ||
@@ -75,0 +75,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
155932
2093