diff --git a/lib/parse.js b/lib/parse.js index 8fd8ff4..64f2045 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -897,6 +897,17 @@ const parse = (input, options) => { continue; } + if (isBrace && rest[0] === '/') { + prev.type = 'globstar'; + prev.value += value; + prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`; + state.output += prev.output; + state.globstar = true; + consume(value + advance()); + push({ type: 'slash', value: '/', output: '' }); + continue; + } + // remove single star from output state.output = state.output.slice(0, -prev.output.length); diff --git a/test/braces.js b/test/braces.js index a343c31..984794a 100644 --- a/test/braces.js +++ b/test/braces.js @@ -146,6 +146,17 @@ describe('braces', () => { assert(isMatch('a/b/bar/baz.qux', 'a/b{,/**}/bar{,/**}/*.*')); }); + it('should support braces with globstars at the start of pattern', () => { + assert(isMatch('a.json', '{**/*.json,**/*.js}')); + assert(isMatch('a.js', '{**/*.json,**/*.js}')); + assert(isMatch('a/b.json', '{**/*.json,**/*.js}')); + assert(isMatch('a/b.js', '{**/*.json,**/*.js}')); + assert(isMatch('foo.md', '{**/foo.md,bar.md}')); + assert(isMatch('a/foo.md', '{**/foo.md,bar.md}')); + assert(isMatch('foo.md', '{bar.md,**/foo.md}')); + assert(isMatch('a/foo.md', '{**/foo.md,bar.md}')); + }); + it('should support Kleene plus', () => { assert(isMatch('ab', '{ab,c}+')); assert(isMatch('abab', '{ab,c}+'));