Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Regex with a period route fails #3301
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
What happens if your regex is greedy? .. e.g., |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
tc
Oct 12, 2011
using the greedy regex works as a workaround, but it's still odd there's a different behavior when using the same regex with resources/match.
tc
commented
Oct 12, 2011
using the greedy regex works as a workaround, but it's still odd there's a different behavior when using the same regex with resources/match. |
ghost
assigned
tenderlove
Oct 12, 2011
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
alindeman
Oct 14, 2011
Contributor
I have yet to verify myself, but I'm betting this has something to do with Rails automatically expecting a .format
at the end of routes. If your regex doesn't capture it, it'll be picked up as a .format
.
To verify, check the value of params[:format]
in your controller when the non-greedy regex is used.
I have yet to verify myself, but I'm betting this has something to do with Rails automatically expecting a To verify, check the value of |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
tc
Oct 15, 2011
That makes sense, but what doesn't is the different behavior of match and resource methods. Shouldn't the params capturing behave the same way?
tc
commented
Oct 15, 2011
That makes sense, but what doesn't is the different behavior of match and resource methods. Shouldn't the params capturing behave the same way? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
@tc Is this still an issue? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
tc
Apr 30, 2012
@alindeman suggested a workaround by using a greedy regex expression.
regex = /[\w\d\s!\.]+?/
greedy_regex = /[\w\d\s!\.]+/
Using the non-greedy regex on http://localhost:3000/embed/Edwin.Lee will capture Edwin(instead of Edwin.Lee) as params[:id]
This can be closed if this is the intended behavior.
tc
commented
Apr 30, 2012
@alindeman suggested a workaround by using a greedy regex expression.
Using the non-greedy regex on http://localhost:3000/embed/Edwin.Lee will capture Edwin(instead of Edwin.Lee) as params[:id] This can be closed if this is the intended behavior. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
@steveklabnik It looks like this issue can be closed. |
tc commentedOct 12, 2011
I have a route file where a regex matcher works in a resource scope but not in the match method:
routes.rb:
pages_controller.rb:
This route works:
http://localhost:3000/pages/Edwin.Lee/embed
id is Edwin.Lee
This one fails:
http://localhost:3000/embed/Edwin.Lee
id is Edwin