minimatch
Advanced tools
Comparing version 4.2.2 to 4.2.3
@@ -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 = () => { | ||
@@ -532,3 +544,3 @@ if (stateChar) { | ||
case '(': | ||
case '(': { | ||
if (inClass) { | ||
@@ -544,3 +556,3 @@ re += '(' | ||
patternListStack.push({ | ||
const plEntry = { | ||
type: stateChar, | ||
@@ -550,19 +562,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)[^/]*) | ||
@@ -572,9 +595,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 += '\\|' | ||
@@ -586,3 +610,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 @@ |
@@ -5,3 +5,3 @@ { | ||
"description": "a glob matcher in javascript", | ||
"version": "4.2.2", | ||
"version": "4.2.3", | ||
"publishConfig": { | ||
@@ -8,0 +8,0 @@ "tag": "legacy-v4" |
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
37164
796