minimatch
Advanced tools
Comparing version
@@ -18,3 +18,3 @@ "use strict"; | ||
// Optimized checking for the most common glob patterns. | ||
const starDotExtRE = /^\*+(\.[^!?\*\[\(]*)$/; | ||
const starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/; | ||
const starDotExtTest = (ext) => (f) => !f.startsWith('.') && f.endsWith(ext); | ||
@@ -38,2 +38,33 @@ const starDotExtTestDot = (ext) => (f) => f.endsWith(ext); | ||
const starTestDot = (f) => f.length !== 0 && f !== '.' && f !== '..'; | ||
const qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/; | ||
const qmarksTestNocase = ([$0, ext = '']) => { | ||
const noext = qmarksTestNoExt([$0]); | ||
if (!ext) | ||
return noext; | ||
ext = ext.toLowerCase(); | ||
return (f) => noext(f) && f.toLowerCase().endsWith(ext); | ||
}; | ||
const qmarksTestNocaseDot = ([$0, ext = '']) => { | ||
const noext = qmarksTestNoExtDot([$0]); | ||
if (!ext) | ||
return noext; | ||
ext = ext.toLowerCase(); | ||
return (f) => noext(f) && f.toLowerCase().endsWith(ext); | ||
}; | ||
const qmarksTestDot = ([$0, ext = '']) => { | ||
const noext = qmarksTestNoExtDot([$0]); | ||
return !ext ? noext : (f) => noext(f) && f.endsWith(ext); | ||
}; | ||
const qmarksTest = ([$0, ext = '']) => { | ||
const noext = qmarksTestNoExt([$0]); | ||
return !ext ? noext : (f) => noext(f) && f.endsWith(ext); | ||
}; | ||
const qmarksTestNoExt = ([$0]) => { | ||
const len = $0.length; | ||
return (f) => f.length === len && !f.startsWith('.'); | ||
}; | ||
const qmarksTestNoExtDot = ([$0]) => { | ||
const len = $0.length; | ||
return (f) => f.length === len && f !== '.' && f !== '..'; | ||
}; | ||
/* c8 ignore start */ | ||
@@ -526,2 +557,11 @@ const platform = typeof process === 'object' && process | ||
} | ||
else if ((m = pattern.match(qmarksRE))) { | ||
fastTest = (options.nocase | ||
? options.dot | ||
? qmarksTestNocaseDot | ||
: qmarksTestNocase | ||
: options.dot | ||
? qmarksTestDot | ||
: qmarksTest)(m); | ||
} | ||
else if ((m = pattern.match(starDotStarRE))) { | ||
@@ -528,0 +568,0 @@ fastTest = options.dot ? starDotStarTestDot : starDotStarTest; |
@@ -11,3 +11,3 @@ export const minimatch = (p, pattern, options = {}) => { | ||
// Optimized checking for the most common glob patterns. | ||
const starDotExtRE = /^\*+(\.[^!?\*\[\(]*)$/; | ||
const starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/; | ||
const starDotExtTest = (ext) => (f) => !f.startsWith('.') && f.endsWith(ext); | ||
@@ -31,2 +31,33 @@ const starDotExtTestDot = (ext) => (f) => f.endsWith(ext); | ||
const starTestDot = (f) => f.length !== 0 && f !== '.' && f !== '..'; | ||
const qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/; | ||
const qmarksTestNocase = ([$0, ext = '']) => { | ||
const noext = qmarksTestNoExt([$0]); | ||
if (!ext) | ||
return noext; | ||
ext = ext.toLowerCase(); | ||
return (f) => noext(f) && f.toLowerCase().endsWith(ext); | ||
}; | ||
const qmarksTestNocaseDot = ([$0, ext = '']) => { | ||
const noext = qmarksTestNoExtDot([$0]); | ||
if (!ext) | ||
return noext; | ||
ext = ext.toLowerCase(); | ||
return (f) => noext(f) && f.toLowerCase().endsWith(ext); | ||
}; | ||
const qmarksTestDot = ([$0, ext = '']) => { | ||
const noext = qmarksTestNoExtDot([$0]); | ||
return !ext ? noext : (f) => noext(f) && f.endsWith(ext); | ||
}; | ||
const qmarksTest = ([$0, ext = '']) => { | ||
const noext = qmarksTestNoExt([$0]); | ||
return !ext ? noext : (f) => noext(f) && f.endsWith(ext); | ||
}; | ||
const qmarksTestNoExt = ([$0]) => { | ||
const len = $0.length; | ||
return (f) => f.length === len && !f.startsWith('.'); | ||
}; | ||
const qmarksTestNoExtDot = ([$0]) => { | ||
const len = $0.length; | ||
return (f) => f.length === len && f !== '.' && f !== '..'; | ||
}; | ||
/* c8 ignore start */ | ||
@@ -514,2 +545,11 @@ const platform = typeof process === 'object' && process | ||
} | ||
else if ((m = pattern.match(qmarksRE))) { | ||
fastTest = (options.nocase | ||
? options.dot | ||
? qmarksTestNocaseDot | ||
: qmarksTestNocase | ||
: options.dot | ||
? qmarksTestDot | ||
: qmarksTest)(m); | ||
} | ||
else if ((m = pattern.match(starDotStarRE))) { | ||
@@ -516,0 +556,0 @@ fastTest = options.dot ? starDotStarTestDot : starDotStarTest; |
@@ -5,3 +5,3 @@ { | ||
"description": "a glob matcher in javascript", | ||
"version": "6.1.7", | ||
"version": "6.1.8", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
175392
2.58%2320
0.96%14
-30%