fewer method calls and string garbage when there is no user/password
This commit is contained in:
parent
5e181ed0ae
commit
6004c753fe
@ -79,7 +79,11 @@ def build_host_url(options)
|
||||
options[:port] = normalize_port(options)
|
||||
|
||||
result << options[:protocol]
|
||||
result << rewrite_authentication(options)
|
||||
|
||||
if options[:user] && options[:password]
|
||||
result << "#{Rack::Utils.escape(options[:user])}:#{Rack::Utils.escape(options[:password])}@"
|
||||
end
|
||||
|
||||
result << options[:host]
|
||||
result << ":#{options[:port]}" if options[:port]
|
||||
end
|
||||
@ -94,14 +98,6 @@ def same_host?(options)
|
||||
(options[:subdomain] == true || !options.key?(:subdomain)) && options[:domain].nil?
|
||||
end
|
||||
|
||||
def rewrite_authentication(options)
|
||||
if options[:user] && options[:password]
|
||||
"#{Rack::Utils.escape(options[:user])}:#{Rack::Utils.escape(options[:password])}@"
|
||||
else
|
||||
""
|
||||
end
|
||||
end
|
||||
|
||||
def normalize_protocol(options)
|
||||
case options[:protocol]
|
||||
when nil
|
||||
|
Loading…
Reference in New Issue
Block a user