aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/http/url.rb
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2014-07-31 13:14:14 -0300
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2014-07-31 13:24:17 -0300
commit0b859dfefe4f267eb86fa6194fa556caae5cb44c (patch)
treeb685b8f0d5cf19fc27a2d2b66a31340bcce6c209 /actionpack/lib/action_dispatch/http/url.rb
parent091a59301f65601b47c7022ac5028b7f6b569e00 (diff)
downloadrails-0b859dfefe4f267eb86fa6194fa556caae5cb44c.tar.gz
rails-0b859dfefe4f267eb86fa6194fa556caae5cb44c.tar.bz2
rails-0b859dfefe4f267eb86fa6194fa556caae5cb44c.zip
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.
Diffstat (limited to 'actionpack/lib/action_dispatch/http/url.rb')
-rw-r--r--actionpack/lib/action_dispatch/http/url.rb13
1 files changed, 5 insertions, 8 deletions
diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb
index 55baba88e4..a7dbceed67 100644
--- a/actionpack/lib/action_dispatch/http/url.rb
+++ b/actionpack/lib/action_dispatch/http/url.rb
@@ -51,9 +51,11 @@ module ActionDispatch
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 @@ module ActionDispatch
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 @@ module ActionDispatch
elsif !path.include?(".")
path.sub!(/[^\/]\z|\A\z/, '\&/')
end
-
- path
end
def build_host_url(host, port, protocol, options, path)