Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove only formats in shortcuts and do it just once.

  • Loading branch information...
commit da32661f10f0d14f392e987c50199c5ee71ed6e8 1 parent 2e3d903
@josevalim josevalim authored
Showing with 5 additions and 4 deletions.
  1. +5 −4 actionpack/lib/action_dispatch/routing/mapper.rb
View
9 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -64,10 +64,11 @@ def extract_path_and_options(args)
end
path = normalize_path(path)
+ path_without_format = path.sub(/\(\.:format\)$/, '')
- if using_match_shorthand?(path, options)
- options[:to] ||= path[1..-1].sub(%r{/([^/]*)$}, '#\1').sub(%r{\(.*\)}, '')
- options[:as] ||= path[1..-1].gsub("/", "_").sub(%r{\(.*\)}, '')
+ if using_match_shorthand?(path_without_format, options)
+ options[:to] ||= path_without_format[1..-1].sub(%r{/([^/]*)$}, '#\1')
+ options[:as] ||= path_without_format[1..-1].gsub("/", "_")
end
[ path, options ]
@@ -80,7 +81,7 @@ def using_to_shorthand?(args, options)
# 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)
Please sign in to comment.
Something went wrong with that request. Please try again.