-
-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add backtrack protection to 6.x (#324)
- Loading branch information
1 parent
28a5b27
commit f1253b4
Showing
5 changed files
with
184 additions
and
55 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
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,21 @@ | ||
import { checkSync } from "recheck"; | ||
import { pathToRegexp } from "./src/index.js"; | ||
|
||
let safe = 0; | ||
let fail = 0; | ||
|
||
const tests = ["/:x{/foobar/:y}?-:z"]; | ||
|
||
for (const path of tests) { | ||
const regexp = pathToRegexp(path); | ||
const result = checkSync(regexp.source, regexp.flags); | ||
if (result.status === "safe") { | ||
safe++; | ||
console.log("Safe:", path, String(regexp)); | ||
} else { | ||
fail++; | ||
console.log("Fail:", path, String(regexp)); | ||
} | ||
} | ||
|
||
console.log("Safe:", safe, "Fail:", fail); |
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
Oops, something went wrong.