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 authored and blakeembrey committed Feb 11, 2022
1 parent 18be995 commit 27766e2
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 @@ -2611,6 +2611,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 27766e2

Please sign in to comment.