diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-06-11 11:33:22 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-06-11 11:33:36 -0700 |
commit | 1c432d1af1399e23fdff8f80bb203da8d3b7cc78 (patch) | |
tree | 1f346251741227c685b902d7256cd63b2cc70dd0 /actionpack | |
parent | a6f30bea06083228739150d3aa717af60dff7fc9 (diff) | |
download | rails-1c432d1af1399e23fdff8f80bb203da8d3b7cc78.tar.gz rails-1c432d1af1399e23fdff8f80bb203da8d3b7cc78.tar.bz2 rails-1c432d1af1399e23fdff8f80bb203da8d3b7cc78.zip |
eliminate nil checks in normalize_port
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/http/url.rb | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb index 593e729411..c4fd05481a 100644 --- a/actionpack/lib/action_dispatch/http/url.rb +++ b/actionpack/lib/action_dispatch/http/url.rb @@ -89,8 +89,9 @@ module ActionDispatch end result << options[:host] - port = normalize_port(options[:port], options[:protocol]) - result << ":#{port}" if port + normalize_port(options[:port], options[:protocol]) { |port| + result << ":#{port}" + } result end @@ -133,15 +134,14 @@ module ActionDispatch end def normalize_port(port, protocol) - return nil if port.nil? || port == false + return unless port case protocol - when "//" - port + when "//" then yield port when "https://" - port.to_i == 443 ? nil : port + yield port unless port.to_i == 443 else - port.to_i == 80 ? nil : port + yield port unless port.to_i == 80 end end end |