diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-06-11 11:27:07 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-06-11 11:33:35 -0700 |
commit | a6f30bea06083228739150d3aa717af60dff7fc9 (patch) | |
tree | e8bf43931e42eb8aaa0a9f822f7578d5bb8441fd /actionpack/lib/action_dispatch/http | |
parent | eec571f99248e5eff42824fb3aa967fc2ac18f4a (diff) | |
download | rails-a6f30bea06083228739150d3aa717af60dff7fc9.tar.gz rails-a6f30bea06083228739150d3aa717af60dff7fc9.tar.bz2 rails-a6f30bea06083228739150d3aa717af60dff7fc9.zip |
reduce hash lookups and disconnect normalize_port from the options hash
Diffstat (limited to 'actionpack/lib/action_dispatch/http')
-rw-r--r-- | actionpack/lib/action_dispatch/http/url.rb | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb index 4cba4f5f37..593e729411 100644 --- a/actionpack/lib/action_dispatch/http/url.rb +++ b/actionpack/lib/action_dispatch/http/url.rb @@ -81,16 +81,16 @@ module ActionDispatch options[:protocol] = normalize_protocol(options) options[:host] = normalize_host(options) - options[:port] = normalize_port(options) - result = options[:protocol] + result = options[:protocol].dup 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] + port = normalize_port(options[:port], options[:protocol]) + result << ":#{port}" if port result end @@ -132,16 +132,16 @@ module ActionDispatch host end - def normalize_port(options) - return nil if options[:port].nil? || options[:port] == false + def normalize_port(port, protocol) + return nil if port.nil? || port == false - case options[:protocol] + case protocol when "//" - options[:port] + port when "https://" - options[:port].to_i == 443 ? nil : options[:port] + port.to_i == 443 ? nil : port else - options[:port].to_i == 80 ? nil : options[:port] + port.to_i == 80 ? nil : port end end end |