minimatch
Advanced tools
Comparing version 5.1.5 to 5.1.6
@@ -443,8 +443,20 @@ const minimatch = module.exports = (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 = () => { | ||
@@ -537,3 +549,3 @@ if (stateChar) { | ||
case '(': | ||
case '(': { | ||
if (inClass) { | ||
@@ -549,3 +561,3 @@ re += '(' | ||
patternListStack.push({ | ||
const plEntry = { | ||
type: stateChar, | ||
@@ -555,19 +567,30 @@ start: i - 1, | ||
open: plTypes[stateChar].open, | ||
close: plTypes[stateChar].close | ||
}) | ||
// negation is (?:(?!js)[^/]*) | ||
re += stateChar === '!' ? '(?:(?!(?:' : '(?:' | ||
close: plTypes[stateChar].close, | ||
} | ||
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 | ||
continue | ||
} | ||
case ')': | ||
if (inClass || !patternListStack.length) { | ||
case ')': { | ||
const plEntry = patternListStack[patternListStack.length - 1] | ||
if (inClass || !plEntry) { | ||
re += '\\)' | ||
continue | ||
} | ||
patternListStack.pop() | ||
// closing an extglob | ||
clearStateChar() | ||
hasMagic = true | ||
pl = patternListStack.pop() | ||
pl = plEntry | ||
// negation is (?:(?!js)[^/]*) | ||
@@ -577,9 +600,10 @@ // The others are (?:<pattern>)<type> | ||
if (pl.type === '!') { | ||
negativeLists.push(pl) | ||
negativeLists.push(Object.assign(pl, { reEnd: re.length })) | ||
} | ||
pl.reEnd = re.length | ||
continue | ||
continue | ||
} | ||
case '|': | ||
if (inClass || !patternListStack.length) { | ||
case '|': { | ||
const plEntry = patternListStack[patternListStack.length - 1] | ||
if (inClass || !plEntry) { | ||
re += '\\|' | ||
@@ -591,3 +615,9 @@ continue | ||
re += '|' | ||
continue | ||
// next subpattern can start with a dot? | ||
if (plEntry.start === 0 && plEntry.type !== '!') { | ||
dotTravAllowed = true | ||
re += subPatternStart(pattern.slice(i + 1)) | ||
} | ||
continue | ||
} | ||
@@ -752,3 +782,3 @@ // these are mostly the same in regexp and glob | ||
if (addPatternStart) { | ||
re = patternStart + re | ||
re = patternStart() + re | ||
} | ||
@@ -755,0 +785,0 @@ |
@@ -8,3 +8,3 @@ { | ||
}, | ||
"version": "5.1.5", | ||
"version": "5.1.6", | ||
"repository": { | ||
@@ -11,0 +11,0 @@ "type": "git", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38919
804