-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Inconsistent trailing slash behaviour with multiple optional parameters #2190
Comments
By having only 2 optional parameters, the parser expects the path to have at least one character. It only makes it fully optional if it's only an optional param. So you can group both params into a single one or create an alias without the params. I'm curious to see what the real route is to see if this is worth supporting or if the alias solution is good enough. Can you please share that? |
The real route is something like this:
|
I realized the previous example doesn't have the optional id, sorry. That one is something like:
which should match It shows a list of videos in swipe screen, and optionally starts at the specific one based on video_id |
I see. Thanks for sharing! Using an alias is indeed the correct solution |
Ok, it would be useful to mention this in the docs, though. I broke a production for a few minutes, it's pretty unexpected behaviour. I'll submit a PR when I have some time to look into it |
…2192) * docs: mention an edge case with mutliple optional params in the docs See #2190 for more info. * Update packages/docs/guide/essentials/route-matching-syntax.md --------- Co-authored-by: Eduardo San Martin Morote <[email protected]>
Reproduction
https://jsfiddle.net/7sg5pry1/
Steps to reproduce the bug
Try route like this:
'/page/:first(a)?:second(b)?'
(clicking the button in the reporduction link)
Expected behavior
It matches:
/page
Text "should be visible" is visible in repro
Actual behavior
Doesn't match
/page
Text "should be visible" is not visible in repro
Additional information
This is inconsistent with the behaviour with only a single optional parameter:
'/page/:first(a)?'
matches/page
Documentation doesn't explicitly mention this case, but implies should that trailing slash is removed in both cases
The text was updated successfully, but these errors were encountered: