Skip to content

Commit

Permalink
fix: treat nocase:true as always having magic
Browse files Browse the repository at this point in the history
Because `a` can match either `A` or `a` in nocase mode, technically
almost any character is "magic".
  • Loading branch information
isaacs committed Feb 13, 2022
1 parent e6bbe1c commit e4cd434
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions minimatch.js
Expand Up @@ -306,7 +306,7 @@ function parse (pattern, isSub) {
if (pattern === '') return ''

var re = ''
var hasMagic = false
var hasMagic = !!options.nocase
var escaping = false
// ? => one single character
var patternListStack = []
Expand Down Expand Up @@ -891,11 +891,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
// patterns with magic have been turned into regexps.
var hit
if (typeof p === 'string') {
if (options.nocase) {
hit = f.toLowerCase() === p.toLowerCase()
} else {
hit = f === p
}
hit = f === p
this.debug('string match', p, f, hit)
} else {
hit = f.match(p)
Expand Down
2 changes: 1 addition & 1 deletion test/patterns.js
Expand Up @@ -330,7 +330,7 @@ module.exports.regexps = [
'/^(?:(?=.)a[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/][^/][^/][^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?)$/',
'/^(?:\\[\\])$/',
'/^(?:\\[abc)$/',
'/^(?:XYZ)$/i',
'/^(?:(?=.)XYZ)$/i',
'/^(?:(?=.)ab[^/]*?)$/i',
'/^(?:(?!\\.)(?=.)[ia][^/][ck])$/i',
'/^(?:\\/(?!\\.)(?=.)[^/]*?|(?!\\.)(?=.)[^/]*?)$/',
Expand Down

0 comments on commit e4cd434

Please sign in to comment.