diff options
author | Diego Carrion <dc.rec1@gmail.com> | 2010-04-16 20:04:29 -0300 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2010-04-17 17:53:08 -0700 |
commit | 8c7e8976e97d96f514e22b04fc1afb9453134076 (patch) | |
tree | d1ec3e09d05b3c9aff260f4e0f489b8db78cf1da /actionpack/lib | |
parent | afcd252205d84ebf5ffd0659301c604a7beba2bb (diff) | |
download | rails-8c7e8976e97d96f514e22b04fc1afb9453134076.tar.gz rails-8c7e8976e97d96f514e22b04fc1afb9453134076.tar.bz2 rails-8c7e8976e97d96f514e22b04fc1afb9453134076.zip |
added shorthand support for routes like /projects/status(.:format)
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 53585740ce..ef2826a4e8 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -66,8 +66,8 @@ module ActionDispatch path = normalize_path(path) if using_match_shorthand?(path, options) - options[:to] ||= path[1..-1].sub(%r{/([^/]*)$}, '#\1') - options[:as] ||= path[1..-1].gsub("/", "_") + options[:to] ||= path[1..-1].sub(%r{/([^/]*)$}, '#\1').sub(%r{\(.*\)}, '') + options[:as] ||= path[1..-1].gsub("/", "_").sub(%r{\(.*\)}, '') end [ path, options ] @@ -80,7 +80,7 @@ module ActionDispatch # match "account/overview" def using_match_shorthand?(path, options) - path && options.except(:via, :anchor, :to, :as).empty? && path =~ %r{^/[\w\/]+$} + path && options.except(:via, :anchor, :to, :as).empty? && path =~ %r{^/[\w+/?]+(\(.*\))*$} end def normalize_path(path) |