Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Push options check up so we can simplify internal methods

  • Loading branch information...
commit 8d61463f34fd0bb7bad446f2d43aaa63fee61563 1 parent 84093c6
@carlosantoniodasilva carlosantoniodasilva authored
Showing with 10 additions and 13 deletions.
  1. +10 −13 actionpack/lib/action_dispatch/http/url.rb
View
23 actionpack/lib/action_dispatch/http/url.rb
@@ -51,28 +51,25 @@ def full_url_for(options)
def path_for(options)
result = options[:script_name].to_s.chomp("/")
result << options[:path].to_s
-
result = add_trailing_slash(result) if options[:trailing_slash]
-
- result = add_params options, result
- add_anchor options, result
+ result = add_params(result, options[:params]) if options.key?(:params)
+ result = add_anchor(result, options[:anchor]) if options.key?(:anchor)
+ result
end
private
- def add_params(options, result)
- if options.key? :params
- param = options[:params]
- params = param.is_a?(Hash) ? param : { params: param }
+ def add_params(result, param)
+ 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
end
- def add_anchor(options, result)
- result << "##{Journey::Router::Utils.escape_fragment(options[:anchor].to_param.to_s)}" if options[:anchor]
+ def add_anchor(result, anchor)
+ result << "##{Journey::Router::Utils.escape_fragment(anchor.to_param.to_s)}"
result
end
Please sign in to comment.
Something went wrong with that request. Please try again.