diff --git a/lib/parse.js b/lib/parse.js index 34bdc2f..bb8e043 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -247,7 +247,7 @@ const parse = (input, options) => { output = token.close = `)$))${extglobStar}`; } - if (token.prev.type === 'bos' && eos()) { + if (token.prev.type === 'bos') { state.negatedExtglob = true; } } diff --git a/test/api.picomatch.js b/test/api.picomatch.js index c5e6b7c..e877ad8 100644 --- a/test/api.picomatch.js +++ b/test/api.picomatch.js @@ -347,4 +347,19 @@ describe('picomatch', () => { }); }); }); + + describe('state', () => { + describe('negatedExtglob', () => { + it('should return true', () => { + assert(picomatch('!(abc)', {}, true).state.negatedExtglob); + assert(picomatch('!(abc)**', {}, true).state.negatedExtglob); + assert(picomatch('!(abc)/**', {}, true).state.negatedExtglob); + }); + + it('should return false', () => { + assert(!picomatch('(!(abc))', {}, true).state.negatedExtglob); + assert(!picomatch('**!(abc)', {}, true).state.negatedExtglob); + }); + }); + }); });