Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

push host / port / protocol extraction up

Then we only need to extract host once.
  • Loading branch information...
commit da57d0b2d4375c09f56c9d94ef78a3d2ce8f4c62 1 parent 41a7c44
@tenderlove tenderlove authored
Showing with 6 additions and 6 deletions.
  1. +6 −6 actionpack/lib/action_dispatch/http/url.rb
View
12 actionpack/lib/action_dispatch/http/url.rb
@@ -29,7 +29,8 @@ def extract_subdomain(host, tld_length)
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 @@ def url_for(options)
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 @@ def add_trailing_slash(path)
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]
Please sign in to comment.
Something went wrong with that request. Please try again.