From 6004c753fed39402fbb014c33a51694d555123de Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 20 May 2014 15:20:16 -0700 Subject: fewer method calls and string garbage when there is no user/password --- actionpack/lib/action_dispatch/http/url.rb | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb index c9860af909..ffba0a82d2 100644 --- a/actionpack/lib/action_dispatch/http/url.rb +++ b/actionpack/lib/action_dispatch/http/url.rb @@ -79,7 +79,11 @@ module ActionDispatch 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 @@ module ActionDispatch (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 -- cgit v1.2.3