提交 da32661f 编写于 作者: J José Valim

Remove only formats in shortcuts and do it just once.

上级 2e3d903e
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册