aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing/mapper.rb
diff options
context:
space:
mode:
authorGonçalo Silva <goncalossilva@gmail.com>2011-03-30 03:24:20 +0100
committerGonçalo Silva <goncalossilva@gmail.com>2011-03-30 03:24:20 +0100
commitb8f9a4515682f2722dc6e8ff9c106f5f774e703b (patch)
tree4c8f2cdc516374b1856963d57dfdaeb212bb2153 /actionpack/lib/action_dispatch/routing/mapper.rb
parent6212749bd48d84e79b728b128bc8a0eabb572106 (diff)
parent58becf116580c37c63b89f4a660ebe293f6e7c4e (diff)
downloadrails-b8f9a4515682f2722dc6e8ff9c106f5f774e703b.tar.gz
rails-b8f9a4515682f2722dc6e8ff9c106f5f774e703b.tar.bz2
rails-b8f9a4515682f2722dc6e8ff9c106f5f774e703b.zip
Merge branch 'master' of https://github.com/rails/rails into performance_test
Diffstat (limited to 'actionpack/lib/action_dispatch/routing/mapper.rb')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 14c424f24b..35be0b3a27 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -104,10 +104,16 @@ module ActionDispatch
@options.reverse_merge!(:controller => /.+?/)
end
+ # Add a constraint for wildcard route to make it non-greedy and match the
+ # optional format part of the route by default
+ if path.match(/\*([^\/]+)$/) && @options[:format] != false
+ @options.reverse_merge!(:"#{$1}" => /.+?/)
+ end
+
if @options[:format] == false
@options.delete(:format)
path
- elsif path.include?(":format") || path.end_with?('/') || path.match(/^\/?\*/)
+ elsif path.include?(":format") || path.end_with?('/')
path
else
"#{path}(.:format)"