aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-06-30 15:37:12 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-06-30 15:37:12 -0700
commitda57d0b2d4375c09f56c9d94ef78a3d2ce8f4c62 (patch)
tree3e146cdcdca5c31791922558fc27ffa87ce8bd83 /actionpack
parent41a7c443a687f0fa3d63620773790ea3b9741e00 (diff)
downloadrails-da57d0b2d4375c09f56c9d94ef78a3d2ce8f4c62.tar.gz
rails-da57d0b2d4375c09f56c9d94ef78a3d2ce8f4c62.tar.bz2
rails-da57d0b2d4375c09f56c9d94ef78a3d2ce8f4c62.zip
push host / port / protocol extraction up
Then we only need to extract host once.
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/http/url.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb
index 3997c6ee98..6ba2820d09 100644
--- a/actionpack/lib/action_dispatch/http/url.rb
+++ b/actionpack/lib/action_dispatch/http/url.rb
@@ -29,7 +29,8 @@ module ActionDispatch
end
def url_for(options)
- unless options[:host] || options[:only_path]
+ host = options[:host]
+ unless host || options[:only_path]
raise ArgumentError, 'Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true'
end
@@ -41,7 +42,9 @@ module ActionDispatch
result = if options[:only_path]
path
else
- build_host_url(options).concat path
+ protocol = options[:protocol]
+ port = options[:port]
+ build_host_url(host, port, protocol, options).concat path
end
if options.key? :params
@@ -80,10 +83,7 @@ module ActionDispatch
path
end
- def build_host_url(options)
- protocol = options[:protocol]
- host = options[:host]
- port = options[:port]
+ def build_host_url(host, port, protocol, options)
if match = host.match(HOST_REGEXP)
protocol ||= match[1] unless protocol == false
host = match[2]