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 e294fbf commit 8532d2d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions minimatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,7 @@ class Minimatch {
// 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 Expand Up @@ -430,7 +426,7 @@ class Minimatch {
if (pattern === '') return ''

let re = ''
let hasMagic = false
let hasMagic = !!options.nocase
let escaping = false
// ? => one single character
const patternListStack = []
Expand Down
2 changes: 1 addition & 1 deletion test/patterns.js
Original file line number Diff line number Diff line change
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 8532d2d

Please sign in to comment.