From db3a60eb92707912461c76895492f6b018b63cc5 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Fri, 28 Mar 2008 20:01:21 +0000 Subject: 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 --- actionpack/lib/action_controller/routing/builder.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/action_controller/routing/builder.rb') diff --git a/actionpack/lib/action_controller/routing/builder.rb b/actionpack/lib/action_controller/routing/builder.rb index 69943d4230..50064055f4 100644 --- a/actionpack/lib/action_controller/routing/builder.rb +++ b/actionpack/lib/action_controller/routing/builder.rb @@ -16,6 +16,10 @@ module ActionController Regexp.new "(.*?)(#{separators.source}|$)" end + def multiline_regexp?(expression) + expression.options & Regexp::MULTILINE == Regexp::MULTILINE + end + # Accepts a "route path" (a string defining a route), and returns the array # of segments that corresponds to it. Note that the segment array is only # partially initialized--the defaults and requirements, for instance, need @@ -99,6 +103,9 @@ module ActionController if requirement.source =~ %r{\A(\\A|\^)|(\\Z|\\z|\$)\Z} raise ArgumentError, "Regexp anchor characters are not allowed in routing requirements: #{requirement.inspect}" end + if multiline_regexp?(requirement) + raise ArgumentError, "Regexp multiline option not allowed in routing requirements: #{requirement.inspect}" + end segment.regexp = requirement else route_requirements[key] = requirement @@ -194,4 +201,4 @@ module ActionController end end end -end \ No newline at end of file +end -- cgit v1.2.3