Skip to content

Commit

Permalink
Merge pull request #348 from amitdahan/fix-brace-pattern
Browse files Browse the repository at this point in the history
Fix braces pattern to support more than 2 choices
  • Loading branch information
mrmlnc committed Jan 9, 2022
2 parents a9247f9 + 7b4d738 commit ef3dcf1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/utils/pattern.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ describe('Utils → Pattern', () => {
assert.ok(util.isDynamicPattern('{a,}'));
assert.ok(util.isDynamicPattern('{,b}'));
assert.ok(util.isDynamicPattern('{a,b}'));
assert.ok(util.isDynamicPattern('{a,b,c}'));
assert.ok(util.isDynamicPattern('{a' + ','.repeat(999999) + 'b}'));
assert.ok(util.isDynamicPattern('{a,b,{c,d}}'));
// The second braces pass
assert.ok(util.isDynamicPattern('{a,b,{c,d}'));
assert.ok(util.isDynamicPattern('{1..3}'));
});

Expand Down
2 changes: 1 addition & 1 deletion src/utils/pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const COMMON_GLOB_SYMBOLS_RE = /[*?]|^!/;
const REGEX_CHARACTER_CLASS_SYMBOLS_RE = /\[[^[]*]/;
const REGEX_GROUP_SYMBOLS_RE = /(?:^|[^!*+?@])\([^(]*\|[^|]*\)/;
const GLOB_EXTENSION_SYMBOLS_RE = /[!*+?@]\([^(]*\)/;
const BRACE_EXPANSIONS_SYMBOLS_RE = /{[^,.{]*(?:,|\.\.)[^,.{]*}/;
const BRACE_EXPANSIONS_SYMBOLS_RE = /{[^,.{]*(?:,|\.\.)[^{]*}/;

type PatternTypeOptions = {
braceExpansion?: boolean;
Expand Down

0 comments on commit ef3dcf1

Please sign in to comment.