-
Notifications
You must be signed in to change notification settings - Fork 368
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
Make part of the path optional, including a string and param #106
Comments
You can't put params inside of the regexp area. What you can do is write your own regexp. Something like |
I thought about using regex as well. But then it's hard to identify parameters as regex only output parameters with the index and parameters count may vary. |
You can prefix it with a param name like in the README. It can always be named or unnamed. |
I can't find how to name parameters when using regex. Can you give me a small example? |
|
For path |
Yes, that's correct. There's no nested matching parameters. I think that's also mentioned in the README (I'm just on mobile now). You'll need to strip the prefix for now, which should be a bit easier with the named params. Nested matching groups is something being considered for the future, but I haven't really figured it out yet (do you end up with two matches? Can you make the outer one non-matching and the inner one matching? How do those params affect indexes or named parameters?). I'll keep this usecase in mind, thanks! |
I have set of filters in my path like this.
/goods/size/:s/brand/:b/color/:c
Now I want to make some of these filters optional so that I will be able to match all of the following paths.
/goods
/goods/size/large
/goods/size/large/brand/abc/color/red
/goods/brand/abc
/goods/size/medium/color/green
How can I do something like that? I'm expecting to have something like this.
/goods(/size/:s)?(/brand/:b)?(/color/:c)?
But seems it's not working.
The text was updated successfully, but these errors were encountered: