Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: mention an edge case with mutliple optional params in the docs #2192

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/docs/guide/essentials/route-matching-syntax.md
Expand Up @@ -114,6 +114,15 @@ const routes = [

Note that `*` technically also marks a parameter as optional but `?` parameters cannot be repeated.

When using multiple optional parameters in succession, the behavior is slightly different because the parser expects at least one of them to match.

```js
const routes = [
// This will match /users/42posva, /users/42, /users/posva but not /users,
{ path: '/users/:userId(\\d+)?:name(\\w+)?' },
]
```

## Debugging

If you need to dig how your routes are transformed into a regex to understand why a route isn't being matched or, to report a bug, you can use the [path ranker tool](https://paths.esm.dev/?p=AAMeJSyAwR4UbFDAFxAcAGAIJXMAAA..#). It supports sharing your routes through the URL.