-
-
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.
Adds strict mode, redos script, improved separator and delimiter
- Loading branch information
1 parent
eaed1fc
commit f73ec6c
Showing
7 changed files
with
3,527 additions
and
3,013 deletions.
There are no files selected for viewing
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
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,36 @@ | ||
import { checkSync } from "recheck"; | ||
import { pathToRegexp } from "../src/index.js"; | ||
|
||
const TESTS = [ | ||
"/abc{abc:foo}?", | ||
"/:foo{abc:foo}?", | ||
"{:attr1}?{:attr2/}?", | ||
"{:attr1/}?{:attr2/}?", | ||
"{:foo.}?{:bar.}?", | ||
"{:foo([^\\.]+).}?{:bar.}?", | ||
":foo(a+):bar(b+)", | ||
]; | ||
|
||
for (const path of TESTS) { | ||
try { | ||
const re = pathToRegexp(path, { strict: true }); | ||
const result = checkSync(re.source, re.flags); | ||
if (result.status === "safe") { | ||
console.log("Safe:", path, String(re)); | ||
} else { | ||
console.log("Fail:", path, String(re)); | ||
} | ||
} catch (err) { | ||
try { | ||
const re = pathToRegexp(path); | ||
const result = checkSync(re.source, re.flags); | ||
if (result.status === "safe") { | ||
console.log("Invalid:", path, String(re)); | ||
} else { | ||
console.log("Pass:", path, String(re)); | ||
} | ||
} catch (err) { | ||
console.log("Error:", path, err.message); | ||
} | ||
} | ||
} |
Oops, something went wrong.