Skip to content

Commit

Permalink
fix: do not skip pattern seperator for square brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmlnc authored and danez committed Apr 10, 2021
1 parent 032e3f5 commit fb08a30
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/scan.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions test/api.scan.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]']);
});
});

Expand Down

0 comments on commit fb08a30

Please sign in to comment.