diff options
author | Diego Carrion <dc.rec1@gmail.com> | 2011-10-10 19:53:42 -0300 |
---|---|---|
committer | Diego Carrion <dc.rec1@gmail.com> | 2011-10-10 19:53:42 -0300 |
commit | 8f863742e34908ed1a9549bb9f984edb58f2b068 (patch) | |
tree | 5d12c5aee476e3cf38653ab2147be131d9b32b7c /actionpack/lib/action_dispatch | |
parent | fcb70f364ccb087f672a85d4d18cc79736503a13 (diff) | |
download | rails-8f863742e34908ed1a9549bb9f984edb58f2b068.tar.gz rails-8f863742e34908ed1a9549bb9f984edb58f2b068.tar.bz2 rails-8f863742e34908ed1a9549bb9f984edb58f2b068.zip |
allow shorthand routes with nested optional parameters
Diffstat (limited to 'actionpack/lib/action_dispatch')
-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 cd59b13c42..ef31d1e004 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -49,7 +49,7 @@ module ActionDispatch class Mapping #:nodoc: IGNORE_OPTIONS = [:to, :as, :via, :on, :constraints, :defaults, :only, :except, :anchor, :shallow, :shallow_path, :shallow_prefix] ANCHOR_CHARACTERS_REGEX = %r{\A(\\A|\^)|(\\Z|\\z|\$)\Z} - SHORTHAND_REGEX = %r{^/[\w/]+$} + SHORTHAND_REGEX = %r{/[\w/]+$} WILDCARD_PATH = %r{\*([^/\)]+)\)?$} def initialize(set, scope, path, options) @@ -70,7 +70,7 @@ module ActionDispatch if using_match_shorthand?(path_without_format, @options) to_shorthand = @options[:to].blank? - @options[:to] ||= path_without_format[1..-1].sub(%r{/([^/]*)$}, '#\1') + @options[:to] ||= path_without_format.gsub(/\(.*\)/, "")[1..-1].sub(%r{/([^/]*)$}, '#\1') end @options.merge!(default_controller_and_action(to_shorthand)) @@ -90,7 +90,7 @@ module ActionDispatch # match "account/overview" def using_match_shorthand?(path, options) - path && options.except(:via, :anchor, :to, :as).empty? && path =~ SHORTHAND_REGEX + path && (options[:to] || options[:action]).nil? && path =~ SHORTHAND_REGEX end def normalize_path(path) |