-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use regex library and reformat regex
I also noticed that there is potential for catastrophic backtracking and hopefully fixed it.
- Loading branch information
1 parent
0a0437c
commit ccce1f5
Showing
4 changed files
with
86 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,5 +39,8 @@ | |
}, | ||
"peerDependencies": { | ||
"prettier": "^3.0.0" | ||
}, | ||
"dependencies": { | ||
"regex": "^4.3.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { parse } from "../src/parser"; | ||
import { ParserOptions } from "prettier"; | ||
|
||
test("benchmark catastrophic backtracking in expression", async () => { | ||
expect( | ||
( | ||
await parse( | ||
"<div>{{ '''''''''''''''''''''''''''''''''' </div>", | ||
{} as ParserOptions, | ||
) | ||
).content, | ||
).toEqual("<div>{{ '''''''''''''''''''''''''''''''''' </div>"); | ||
}); | ||
|
||
test("benchmark catastrophic backtracking in statement", async () => { | ||
expect( | ||
( | ||
await parse( | ||
"<div>{% for '''''''''''''''''''''''''''''''''''' </div>", | ||
{} as ParserOptions, | ||
) | ||
).content, | ||
).toEqual("<div>{% for '''''''''''''''''''''''''''''''''''' </div>"); | ||
}); |