Skip to content

Commit

Permalink
Merge pull request #342 from Trott/cliff
Browse files Browse the repository at this point in the history
fix: remove performance cliff for regex
  • Loading branch information
mrmlnc authored Jan 4, 2022
2 parents 95838d1 + fe57c2b commit 3325450
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/utils/pattern.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ describe('Utils → Pattern', () => {

it('should return false for unfinished regex group', () => {
assert.ok(!util.isDynamicPattern('(a|b'));
assert.ok(!util.isDynamicPattern('('.repeat(999999) + 'a|b'));
assert.ok(!util.isDynamicPattern('(a' + '|'.repeat(999999) + 'b'));
assert.ok(!util.isDynamicPattern('abc/(a|b'));
});

Expand Down
2 changes: 1 addition & 1 deletion src/utils/pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const ESCAPE_SYMBOL = '\\';

const COMMON_GLOB_SYMBOLS_RE = /[*?]|^!/;
const REGEX_CHARACTER_CLASS_SYMBOLS_RE = /\[[^[]*]/;
const REGEX_GROUP_SYMBOLS_RE = /(?:^|[^!*+?@])\(.*\|.*\)/;
const REGEX_GROUP_SYMBOLS_RE = /(?:^|[^!*+?@])\([^(]*\|[^|]*\)/;
const GLOB_EXTENSION_SYMBOLS_RE = /[!*+?@]\(.*\)/;
const BRACE_EXPANSIONS_SYMBOLS_RE = /{.*(?:,|\.\.).*}/;

Expand Down

0 comments on commit 3325450

Please sign in to comment.