wild card route weird behavior
See original GitHub issueI’m submitting a …
- bug report
- feature request
- other (Please do not submit support requests here (below))
Routes definition:
const routes = {
path: '',
children: [
// paths
{
path: '(.*)'
action(context, params) {
console.log(params);
}
]
}
Going to the route / -which I don’t have a defined route for - will log this to the console
{0: '/'}
The problem is that defining the path as (.*)
will create an unnamed parameter with the value ‘/’, and defining the path like this /(.*)
will create an unnamed parameter with value ‘’ (empty string).
I use a generic action because I handle all my routes in the same way, so suddenly I find the url of my app looks like this ‘/?0=%2F’ or like this ‘?0=’ or worse - if I go to ‘blah’ the url will look like this ‘/?=%2Fblah’
I’ve read the path-to-regex documentation, and I found out that this is the desired behavior for the unnamed parameters (.*)
, but this is not the desired behavior for wild card path.
Please provide another way to handle wild card paths, while keeping the same behavior for unnamed parameters, as they are not the same case.
Side note: I love your work, I have been searching for a universal router for about a year before I have found your package, and I have not used any other router since. Brilliant work, great flexibility. I will submit a PR soon to add more recipes.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Have you tried to use regexp
path: /.*/,
? https://jsfiddle.net/b0w9mjck/118/This should be mentioned in the read me