Replies: 1 comment
-
|
@jotpal07 Do you have a more clear example of what's failing? It works fine when I'm running a test locally: > match('{/:stage}/url/path')('/url/path')
{ path: '/url/path', params: [Object: null prototype] {} }
> match('{/:stage}/url/path')('/dev/url/path')
{
path: '/dev/url/path',
params: [Object: null prototype] { stage: 'dev' }
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I know a similar question has been asked before here #338 but mine is a different scenario.
Previously, the route pattern
:stage?/url/pathworked with an optional:stage?parameter — it matched both when a stage was provided (e.g.,http://localhost/devstage/url/path) and when it was omitted (e.g.,http://localhost/url/path).However, this no longer seems to work when the optional
:stageparameter is placed at the beginning of the route. In this case, the route only matches if a stage name is provided — it does not match the URL when the stage is omitted.To make both cases work, the optional parameter needs to be placed after a static segment. For example, using
stagename{/:stage}/url/pathallows both of the following URLs to match correctlyhttp://localhost/stagename/devstage/url/pathhttp://localhost/stagename/url/pathIt appears that the optional parameter
{/:stage}only works when it's not at the beginning of the route.is this the expected behavior? And if so, is it possible to fix it so that optional parameters also work when placed at the beginning of the route?
Beta Was this translation helpful? Give feedback.
All reactions