diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2008-03-28 20:01:21 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2008-03-28 20:01:21 +0000 |
commit | db3a60eb92707912461c76895492f6b018b63cc5 (patch) | |
tree | 3d5c9bc2a3d17fe9e2b5193397a010b9de32914f /actionpack/lib/action_controller/routing/segments.rb | |
parent | 9300ebd86fa39c6ea96cf39ef50ba5337dca6157 (diff) | |
download | rails-db3a60eb92707912461c76895492f6b018b63cc5.tar.gz rails-db3a60eb92707912461c76895492f6b018b63cc5.tar.bz2 rails-db3a60eb92707912461c76895492f6b018b63cc5.zip |
Added support for regexp flags like ignoring case in the :requirements part of routes declarations (closes #11421) [NeilW]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9115 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/routing/segments.rb')
-rw-r--r-- | actionpack/lib/action_controller/routing/segments.rb | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/routing/segments.rb b/actionpack/lib/action_controller/routing/segments.rb index efac2df1cb..24ea8c7f2d 100644 --- a/actionpack/lib/action_controller/routing/segments.rb +++ b/actionpack/lib/action_controller/routing/segments.rb @@ -171,10 +171,19 @@ module ActionController end def value_regexp - Regexp.new "\\A#{regexp.source}\\Z" if regexp + Regexp.new "\\A#{regexp.to_s}\\Z" if regexp end + def regexp_chunk - regexp ? "(#{regexp.source})" : "([^#{Routing::SEPARATORS.join}]+)" + if regexp + if regexp_has_modifiers? + "(#{regexp.to_s})" + else + "(#{regexp.source})" + end + else + "([^#{Routing::SEPARATORS.join}]+)" + end end def build_pattern(pattern) @@ -183,6 +192,7 @@ module ActionController pattern = "#{chunk}#{pattern}" optional? ? Regexp.optionalize(pattern) : pattern end + def match_extraction(next_capture) # All non code-related keys (such as :id, :slug) are URI-unescaped as # path parameters. @@ -201,6 +211,10 @@ module ActionController [:action, :id].include? key end + def regexp_has_modifiers? + regexp.options & (Regexp::IGNORECASE | Regexp::EXTENDED) != 0 + end + end class ControllerSegment < DynamicSegment #:nodoc: |