aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing/mapper.rb
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2010-11-16 21:46:15 -0800
committerCarl Lerche <me@carllerche.com>2010-11-16 21:46:15 -0800
commit401c1835afb5af1a6f429061ac8484227c34909d (patch)
treead2ea9a395e78fd5fa09fb4725aeee340768cf4d /actionpack/lib/action_dispatch/routing/mapper.rb
parent1deeaf5495036dd7541e2085e8311c57e7130f0a (diff)
downloadrails-401c1835afb5af1a6f429061ac8484227c34909d.tar.gz
rails-401c1835afb5af1a6f429061ac8484227c34909d.tar.bz2
rails-401c1835afb5af1a6f429061ac8484227c34909d.zip
Anchors should be allowed on constraints that are not on path segments
Diffstat (limited to 'actionpack/lib/action_dispatch/routing/mapper.rb')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb21
1 files changed, 12 insertions, 9 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 53a52b735e..879ccc5791 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -66,6 +66,18 @@ module ActionDispatch
end
@options.merge!(default_controller_and_action(to_shorthand))
+
+ requirements.each do |name, requirement|
+ # segment_keys.include?(k.to_s) || k == :controller
+ next unless Regexp === requirement && !constraints[name]
+
+ if requirement.source =~ %r{\A(\\A|\^)|(\\Z|\\z|\$)\Z}
+ raise ArgumentError, "Regexp anchor characters are not allowed in routing requirements: #{requirement.inspect}"
+ end
+ if requirement.multiline?
+ raise ArgumentError, "Regexp multiline option not allowed in routing requirements: #{requirement.inspect}"
+ end
+ end
end
# match "account/overview"
@@ -113,15 +125,6 @@ module ActionDispatch
@requirements ||= (@options[:constraints].is_a?(Hash) ? @options[:constraints] : {}).tap do |requirements|
requirements.reverse_merge!(@scope[:constraints]) if @scope[:constraints]
@options.each { |k, v| requirements[k] = v if v.is_a?(Regexp) }
-
- requirements.values.grep(Regexp).each do |requirement|
- if requirement.source =~ %r{\A(\\A|\^)|(\\Z|\\z|\$)\Z}
- raise ArgumentError, "Regexp anchor characters are not allowed in routing requirements: #{requirement.inspect}"
- end
- if requirement.multiline?
- raise ArgumentError, "Regexp multiline option not allowed in routing requirements: #{requirement.inspect}"
- end
- end
end
end