Skip to content

Commit

Permalink
fix case where ) appears in a class in an extglob
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Jan 17, 2023
1 parent 9ddf1df commit 35b00ba
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -760,11 +760,12 @@ export class Minimatch {
}

case ')': {
const plEntry = patternListStack.pop()
const plEntry = patternListStack[patternListStack.length - 1]
if (inClass || !plEntry) {
re += '\\)'
continue
}
patternListStack.pop()

// closing an extglob
clearStateChar()
Expand Down
8 changes: 8 additions & 0 deletions tap-snapshots/test/basic.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ exports[`test/basic.js TAP basic tests > makeRe @(.*|js) 1`] = `
/^(?:(?=.)(?:\\.[^/]*?|(?!\\.)js))$/
`

exports[`test/basic.js TAP basic tests > makeRe @(a|a[(])b 1`] = `
/^(?:(?=.)(?:(?!\\.)a|(?!\\.)a[(])b)$/
`

exports[`test/basic.js TAP basic tests > makeRe @(a|a[)])b 1`] = `
/^(?:(?=.)(?:(?!\\.)a|(?!\\.)a[\\)])b)$/
`

exports[`test/basic.js TAP basic tests > makeRe @(js|.*) 1`] = `
/^(?:(?=.)(?:(?!\\.)js|\\.[^/]*?))$/
`
Expand Down
3 changes: 3 additions & 0 deletions test/patterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@ module.exports = [
// doesn't start at 0, no dice
// neg extglobs don't trigger this behavior.
['!(.a|js)@(.*)', ['a.js'], { nonegate: true }],
() => files=['a(b', 'ab', 'a)b'],
['@(a|a[(])b', ['a(b', 'ab']],
['@(a|a[)])b', ['a)b', 'ab']],
]

Object.defineProperty(module.exports, 'files', {
Expand Down

0 comments on commit 35b00ba

Please sign in to comment.