Skip to content

Commit 27766e2

Browse files
kettanaitoblakeembrey
authored andcommitted
Wrap parameter with "+" modifier in a non-capturing group
1 parent 18be995 commit 27766e2

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/index.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2611,6 +2611,21 @@ const TESTS: Test[] = [
26112611
[["foobar", ["foobar", "foobar"]]],
26122612
[[{ name: "foobar" }, "foobar"]],
26132613
],
2614+
[
2615+
":name+",
2616+
undefined,
2617+
[
2618+
{
2619+
name: "name",
2620+
prefix: "",
2621+
suffix: "",
2622+
modifier: "+",
2623+
pattern: "[^\\/#\\?]+?",
2624+
},
2625+
],
2626+
[["foobar", ["foobar", "foobar"]]],
2627+
[[{ name: "foobar" }, "foobar"]],
2628+
],
26142629
];
26152630

26162631
/**

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ export function tokensToRegexp(
563563
route += `(?:${prefix}(${token.pattern})${suffix})${token.modifier}`;
564564
}
565565
} else {
566-
if (token.modifier === "*") {
566+
if (token.modifier === "+" || token.modifier === "*") {
567567
route += `((?:${token.pattern})${token.modifier})`;
568568
} else {
569569
route += `(${token.pattern})${token.modifier}`;

0 commit comments

Comments
 (0)