extract method on determining :to from the path
Eventually we'll pull this up and delete `process_path`.
This commit is contained in:
parent
b10b279b97
commit
b543ee74f4
@ -1564,19 +1564,23 @@ def match(path, *rest)
|
|||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_path(options, controller, path, option_path, to, via, formatted, ancho, options_constraintsr)
|
def get_to_from_path(path, to, action)
|
||||||
|
return to if to || action
|
||||||
|
|
||||||
path_without_format = path.sub(/\(\.:format\)$/, '')
|
path_without_format = path.sub(/\(\.:format\)$/, '')
|
||||||
if using_match_shorthand?(path_without_format, to, options[:action])
|
if using_match_shorthand?(path_without_format)
|
||||||
to ||= path_without_format.gsub(%r{^/}, "").sub(%r{/([^/]*)$}, '#\1')
|
to ||= path_without_format.gsub(%r{^/}, "").sub(%r{/([^/]*)$}, '#\1')
|
||||||
to.tr!("-", "_")
|
to.tr!("-", "_")
|
||||||
end
|
end
|
||||||
|
to
|
||||||
|
end
|
||||||
|
|
||||||
|
def process_path(options, controller, path, option_path, to, via, formatted, ancho, options_constraintsr)
|
||||||
|
to = get_to_from_path(path, to, options[:action])
|
||||||
decomposed_match(path, controller, options, option_path, to, via, formatted, ancho, options_constraintsr)
|
decomposed_match(path, controller, options, option_path, to, via, formatted, ancho, options_constraintsr)
|
||||||
end
|
end
|
||||||
|
|
||||||
def using_match_shorthand?(path, to, action)
|
def using_match_shorthand?(path)
|
||||||
return false if to || action
|
|
||||||
|
|
||||||
path =~ %r{^/?[-\w]+/[-\w/]+$}
|
path =~ %r{^/?[-\w]+/[-\w/]+$}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user