From fb08a301388a6bbf7e8b86409df70051aabcbc92 Mon Sep 17 00:00:00 2001 From: mrmlnc Date: Fri, 18 Dec 2020 23:27:01 +0300 Subject: [PATCH] fix: do not skip pattern seperator for square brackets --- lib/scan.js | 10 ++++++---- test/api.scan.js | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/scan.js b/lib/scan.js index 31ae6ad..456c2f8 100644 --- a/lib/scan.js +++ b/lib/scan.js @@ -231,13 +231,15 @@ const scan = (input, options) => { isBracket = token.isBracket = true; isGlob = token.isGlob = true; finished = true; - - if (scanToEnd === true) { - continue; - } break; } } + + if (scanToEnd === true) { + continue; + } + + break; } if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) { diff --git a/test/api.scan.js b/test/api.scan.js index cb9911d..2f2c14b 100644 --- a/test/api.scan.js +++ b/test/api.scan.js @@ -311,6 +311,10 @@ describe('picomatch', () => { assertParts('XXX/*/*/12/*/*/m/*/*', ['XXX', '*', '*', '12', '*', '*', 'm', '*', '*']); assertParts('foo/\\"**\\"/bar', ['foo', '\\"**\\"', 'bar']); + + assertParts('[0-9]/[0-9]', ['[0-9]', '[0-9]']); + assertParts('foo/[0-9]/[0-9]', ['foo', '[0-9]', '[0-9]']); + assertParts('foo[0-9]/bar[0-9]', ['foo[0-9]', 'bar[0-9]']); }); });