Skip to content

Commit

Permalink
Update packages/docs/guide/essentials/route-matching-syntax.md
Browse files Browse the repository at this point in the history
  • Loading branch information
posva authored Jul 9, 2024
1 parent 97e1df9 commit ac4e94b
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions packages/docs/guide/essentials/route-matching-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,12 @@ 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.
If the route segment contains more than **just an optional parameter**, it won't match a path **without the trailing slash**. For example:

```js
const routes = [
// This will match /users/42posva, /users/42, /users/posva but not /users,
{ path: '/users/:userId(\\d+)?:name(\\w+)?' },
]
```
- `/users/:uid?-:name?` won't match `/users`, only `/users/-` or even `/users/-/`
- `/users/:uid(\\d+)?:name? won't match `/users`, only `/users/`, `/users/2`, `/users/2/`, etc

You can play around with the matching syntax [in the playground](https://paths.esm.dev/?p=AAMsIPQg4AoKzidgQFoEXAmw-IEBBRYYOE0SkABTASiz1qgBpgQA1QTsFjAb3h2onsmlAmGIFsCXjXh4AIA.&t=/users/2/#)

## Debugging

Expand Down

0 comments on commit ac4e94b

Please sign in to comment.