From 55dda291dfb595bd11b4edb19b45dd98eda76de0 Mon Sep 17 00:00:00 2001 From: isaacs Date: Sat, 12 Feb 2022 18:17:12 -0800 Subject: [PATCH] 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". --- minimatch.js | 8 ++------ test/patterns.js | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/minimatch.js b/minimatch.js index e07c58f1..b0e2e814 100644 --- a/minimatch.js +++ b/minimatch.js @@ -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 = [] @@ -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) diff --git a/test/patterns.js b/test/patterns.js index 4167b78f..ac79b439 100644 --- a/test/patterns.js +++ b/test/patterns.js @@ -330,7 +330,7 @@ module.exports.regexps = [ '/^(?:(?=.)a[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/][^/][^/][^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?)$/', '/^(?:\\[\\])$/', '/^(?:\\[abc)$/', - '/^(?:XYZ)$/i', + '/^(?:(?=.)XYZ)$/i', '/^(?:(?=.)ab[^/]*?)$/i', '/^(?:(?!\\.)(?=.)[ia][^/][ck])$/i', '/^(?:\\/(?!\\.)(?=.)[^/]*?|(?!\\.)(?=.)[^/]*?)$/',