Closed mcardia closed 6 years ago
Hi @mcardia
Thanks for your comment. You just found a bug in the router_
.
I just updated the master branch with the fix.
It's a simple line of code, you can update it yourself instead of waiting for a new release.
Thank you for the fast reply.
now works if i add ? do the dash. Like this:
elsif route_.get ('img/{id}/?{d}?', p) then
The way it is in documentation still don´t work.
elsif route_.get ('img/{id}/{d}?', p) then
Could be any side effects using the way i did?
Thanks.
Hi @mcardia
Indeed, that is the correct thing to do. I have to update the documentation to make it clear.
I have passed some tests and I have not found any side effects, I added more test and these are the results:
**********
Routing with optional parameters. The documentation example
**********
- The input path is `user` the regular expression: user/?{Id}?/?{Name}?
l_param ('id') =
l_param ('name') =
Pass
- The input path is `user/` the regular expression: user/?{Id}?/?{Name}?
l_param ('id') =
l_param ('name') =
Pass
- The input path is `user/id` the regular expression: user/?{Id}?/?{Name}?
l_param ('id') = id
l_param ('name') =
Pass
- The input path is `user/id/` the regular expression: user/?{Id}?/?{Name}?
l_param ('id') = id
l_param ('name') =
Pass
- The input path is `user/id/name` the regular expression: user/?{Id}?/?{Name}?
l_param ('id') = id
l_param ('name') = name
Pass
- The input path is `user/id/name/` the regular expression: user/?{Id}?/?{Name}?
l_param ('id') = id
l_param ('name') = name
Pass
Hi! Great project!
A doubt: How can I use optional parameters in router without last slash?
Example: My route is
...if route_.get ('img/{img_id}/{d}?', p) then...
app?p=/img/20137/275x275 works app?p=/img/20137/ works app?p=/img/20137 don't work.
I tried:
...if route_.get ('img/{img_id}/?{d}?', p) then...
...if route_.get ('img/{img_id}(/{d})?', p) then...
...if route_.get ('img/{img_id}/?({d})?', p) then...
neither worked...
Thank you.