提交 8d61463f 编写于 作者: C Carlos Antonio da Silva

Push options check up so we can simplify internal methods

上级 84093c66
...@@ -51,28 +51,25 @@ def full_url_for(options) ...@@ -51,28 +51,25 @@ def full_url_for(options)
def path_for(options) def path_for(options)
result = options[:script_name].to_s.chomp("/") result = options[:script_name].to_s.chomp("/")
result << options[:path].to_s result << options[:path].to_s
result = add_trailing_slash(result) if options[:trailing_slash] result = add_trailing_slash(result) if options[:trailing_slash]
result = add_params(result, options[:params]) if options.key?(:params)
result = add_params options, result result = add_anchor(result, options[:anchor]) if options.key?(:anchor)
add_anchor options, result result
end end
private private
def add_params(options, result) def add_params(result, param)
if options.key? :params params = param.is_a?(Hash) ? param : { params: param }
param = options[:params]
params = param.is_a?(Hash) ? param : { params: param } params.reject! { |_,v| v.to_param.nil? }
result << "?#{params.to_query}" unless params.empty?
params.reject! { |_,v| v.to_param.nil? }
result << "?#{params.to_query}" unless params.empty?
end
result result
end end
def add_anchor(options, result) def add_anchor(result, anchor)
result << "##{Journey::Router::Utils.escape_fragment(options[:anchor].to_param.to_s)}" if options[:anchor] result << "##{Journey::Router::Utils.escape_fragment(anchor.to_param.to_s)}"
result result
end end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册