Skip to content

Commit 55dda29

Browse files
committed
fix: treat nocase:true as always having magic
Because `a` can match either `A` or `a` in nocase mode, technically almost any character is "magic".
1 parent 5e1fb8d commit 55dda29

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

minimatch.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ function parse (pattern, isSub) {
306306
if (pattern === '') return ''
307307

308308
var re = ''
309-
var hasMagic = false
309+
var hasMagic = !!options.nocase
310310
var escaping = false
311311
// ? => one single character
312312
var patternListStack = []
@@ -891,11 +891,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
891891
// patterns with magic have been turned into regexps.
892892
var hit
893893
if (typeof p === 'string') {
894-
if (options.nocase) {
895-
hit = f.toLowerCase() === p.toLowerCase()
896-
} else {
897-
hit = f === p
898-
}
894+
hit = f === p
899895
this.debug('string match', p, f, hit)
900896
} else {
901897
hit = f.match(p)

test/patterns.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ module.exports.regexps = [
330330
'/^(?:(?=.)a[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/][^/][^/][^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?)$/',
331331
'/^(?:\\[\\])$/',
332332
'/^(?:\\[abc)$/',
333-
'/^(?:XYZ)$/i',
333+
'/^(?:(?=.)XYZ)$/i',
334334
'/^(?:(?=.)ab[^/]*?)$/i',
335335
'/^(?:(?!\\.)(?=.)[ia][^/][ck])$/i',
336336
'/^(?:\\/(?!\\.)(?=.)[^/]*?|(?!\\.)(?=.)[^/]*?)$/',

0 commit comments

Comments
 (0)