Skip to content
Browse files

Do not reassign variable when mutation is happening

These methods mutate the path variable/argument so there is no need
to reassign it every time.
  • Loading branch information...
1 parent 091a593 commit 0b859dfefe4f267eb86fa6194fa556caae5cb44c @carlosantoniodasilva carlosantoniodasilva committed Jul 31, 2014
Showing with 5 additions and 8 deletions.
  1. +5 −8 actionpack/lib/action_dispatch/http/url.rb
View
13 actionpack/lib/action_dispatch/http/url.rb
@@ -51,9 +51,11 @@ def full_url_for(options)
def path_for(options)
path = options[:script_name].to_s.chomp("/")
path << options[:path] if options.key?(:path)
- path = add_trailing_slash(path) if options[:trailing_slash]
- path = add_params(path, options[:params]) if options.key?(:params)
- path = add_anchor(path, options[:anchor]) if options.key?(:anchor)
+
+ add_trailing_slash(path) if options[:trailing_slash]
+ add_params(path, options[:params]) if options.key?(:params)
+ add_anchor(path, options[:anchor]) if options.key?(:anchor)
+
path
end
@@ -63,13 +65,10 @@ def add_params(path, params)
params = { params: params } unless params.is_a?(Hash)
params.reject! { |_,v| v.to_param.nil? }
path << "?#{params.to_query}" unless params.empty?
-
- path
end
def add_anchor(path, anchor)
path << "##{Journey::Router::Utils.escape_fragment(anchor.to_param.to_s)}"
- path
end
def extract_domain_from(host, tld_length)
@@ -89,8 +88,6 @@ def add_trailing_slash(path)
elsif !path.include?(".")
path.sub!(/[^\/]\z|\A\z/, '\&/')
end
-
- path
end
def build_host_url(host, port, protocol, options, path)

0 comments on commit 0b859df

Please sign in to comment.
Something went wrong with that request. Please try again.