diff --git a/package-lock.json b/package-lock.json index f5457c7b..63f4ec6e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "minimatch", - "version": "6.1.0", + "version": "6.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "minimatch", - "version": "6.1.0", + "version": "6.1.1", "license": "ISC", "dependencies": { "brace-expansion": "^2.0.1" diff --git a/package.json b/package.json index cc9de401..e764a4ec 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Isaac Z. Schlueter (http://blog.izs.me)", "name": "minimatch", "description": "a glob matcher in javascript", - "version": "6.1.0", + "version": "6.1.1", "repository": { "type": "git", "url": "git://github.com/isaacs/minimatch.git" diff --git a/src/index.ts b/src/index.ts index 0601010c..3ff35b16 100644 --- a/src/index.ts +++ b/src/index.ts @@ -907,7 +907,8 @@ export class Minimatch { // Handle nested stuff like *(*.js|!(*.json)), where open parens // mean that we should *not* include the ) in the bit that is considered // "after" the negated section. - const openParensBefore = nlBefore.split('(').length - 1 + const closeParensBefore = nlBefore.split(')').length + const openParensBefore = nlBefore.split('(').length - closeParensBefore let cleanAfter = nlAfter for (let i = 0; i < openParensBefore; i++) { cleanAfter = cleanAfter.replace(/\)[+*?]?/, '') diff --git a/tap-snapshots/test/basic.js.test.cjs b/tap-snapshots/test/basic.js.test.cjs index bd2a6a71..becc8ff4 100644 --- a/tap-snapshots/test/basic.js.test.cjs +++ b/tap-snapshots/test/basic.js.test.cjs @@ -109,6 +109,10 @@ exports[`test/basic.js TAP basic tests > makeRe *c*?** 1`] = ` /^(?:(?!\\.)(?=.)[^/]*?c[^/]*?[^/][^/]*?[^/]*?)$/ ` +exports[`test/basic.js TAP basic tests > makeRe +(a)!(b)+(c) 1`] = ` +/^(?:(?!\\.)(?=.)(?:a)+(?:(?!(?:b)(?:c)+)[^/]*?)(?:c)+)$/ +` + exports[`test/basic.js TAP basic tests > makeRe +(a|*\\|c\\\\|d\\\\\\|e\\\\\\\\|f\\\\\\\\\\|g 1`] = ` /^(?:(?=.)\\+\\(a\\|[^/]*?\\|c\\\\\\\\\\|d\\\\\\\\\\|e\\\\\\\\\\\\\\\\\\|f\\\\\\\\\\\\\\\\\\|g)$/ ` diff --git a/test/patterns.js b/test/patterns.js index 81144b8a..12b7e785 100644 --- a/test/patterns.js +++ b/test/patterns.js @@ -311,6 +311,22 @@ module.exports = [ ['[z\\-a]', []], ['[\\-\\]]', []], ['[a-b-c]', []], + + // https://github.com/isaacs/node-glob/issues/415 + () => { + files = [ + 'ac', + 'abc', + 'acd', + 'acc', + 'acd', + 'adc', + 'bbc', + 'bac', + 'bcc', + ] + }, + ['+(a)!(b)+(c)', ['ac', 'acc', 'adc']], ] Object.defineProperty(module.exports, 'files', {