Akira
2008-Apr-14 03:16 UTC
routes.rb: regular expression /i (case insensitive) doesn''t work?
Dear all, I have something like this in routes.rb: map.connect '':test'', :controller => ''help'', :requirements => { :test => /apple/i } But then, the routing for URL "/apple" works but "/APPLE" does not! Why doesn''t the i-for-case-insensitive work? Is this by-design or a bug? Thanks for any advice, AK --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mark Bush
2008-Apr-14 07:57 UTC
Re: routes.rb: regular expression /i (case insensitive) does
Akira wrote:> map.connect '':test'', :controller => ''help'', :requirements => { :test > => /apple/i } > > But then, the routing for URL "/apple" works but "/APPLE" does not!Because Rails doesn''t use the regular expression as-is. It decides that you always want the expression to be anchored at the start and end. The code used is: requirement_conditions = requirements.collect do |key, req| if req.is_a? Regexp value_regexp = Regexp.new "\\A#{req.source}\\Z" So only the source string of your regular expression is used. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---