Permalink
Browse files

fewer method calls and string garbage when there is no user/password

  • Loading branch information...
1 parent 5e181ed commit 6004c753fed39402fbb014c33a51694d555123de @tenderlove tenderlove committed May 20, 2014
Showing with 5 additions and 9 deletions.
  1. +5 −9 actionpack/lib/action_dispatch/http/url.rb
@@ -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

0 comments on commit 6004c75

Please sign in to comment.