Skip to content

Commit

Permalink
Wrap parameter with "+" modifier in a non-capturing group
Browse files Browse the repository at this point in the history
  • Loading branch information
kettanaito committed Aug 27, 2021
1 parent 9251d85 commit 80d4d03
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2610,6 +2610,21 @@ const TESTS: Test[] = [
],
[["foobar", ["foobar", "foobar"]]],
[[{ name: "foobar" }, "foobar"]]
],
[
":name+",
undefined,
[
{
name: "name",
prefix: "",
suffix: "",
modifier: "+",
pattern: "[^\\/#\\?]+?",
},
],
[["foobar", ["foobar", "foobar"]]],
[[{ name: "foobar" }, "foobar"]],
]
];

Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ export function tokensToRegexp(
route += `(?:${prefix}(${token.pattern})${suffix})${token.modifier}`;
}
} else {
if (token.modifier === "*") {
if (token.modifier === "+" || token.modifier === "*") {
route += `((?:${token.pattern})${token.modifier})`;
} else {
route += `(${token.pattern})${token.modifier}`;
Expand Down

0 comments on commit 80d4d03

Please sign in to comment.