aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/http/url.rb
diff options
context:
space:
mode:
authorJosh Kalderimis <josh.kalderimis@gmail.com>2010-11-24 10:10:38 +0100
committerJosé Valim <jose.valim@gmail.com>2010-11-24 10:34:18 +0100
commite39138478b38d7a5e0a13756b1bdfa8b43226846 (patch)
tree6bfb66786c4a92dbf02004711fc06307a2d93dd4 /actionpack/lib/action_dispatch/http/url.rb
parent0687b21de879d53157e52a2b688e34a1bd1e31f0 (diff)
downloadrails-e39138478b38d7a5e0a13756b1bdfa8b43226846.tar.gz
rails-e39138478b38d7a5e0a13756b1bdfa8b43226846.tar.bz2
rails-e39138478b38d7a5e0a13756b1bdfa8b43226846.zip
port_string bought back to life as it is part of the public api
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack/lib/action_dispatch/http/url.rb')
-rw-r--r--actionpack/lib/action_dispatch/http/url.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb
index 1f7633cbea..1e7054f381 100644
--- a/actionpack/lib/action_dispatch/http/url.rb
+++ b/actionpack/lib/action_dispatch/http/url.rb
@@ -52,8 +52,7 @@ module ActionDispatch
# Returns a \host:\port string for this request, such as "example.com" or
# "example.com:8080".
def host_with_port
- opt_port = optional_port ? ":#{optional_port}" : nil
- "#{host}#{opt_port}"
+ "#{host}#{port_string}"
end
# Returns the port number of this request as an integer.
@@ -80,12 +79,18 @@ module ActionDispatch
port == standard_port
end
- # Returns a \port suffix like "8080" if the \port number of this request
+ # Returns a number \port suffix like 8080 if the \port number of this request
# is not the default HTTP \port 80 or HTTPS \port 443.
def optional_port
standard_port? ? nil : port
end
+ # Returns a string \port suffix, including colon, like ":8080" if the \port
+ # number of this request is not the default HTTP \port 80 or HTTPS \port 443.
+ def port_string
+ standard_port? ? '' : ":#{port}"
+ end
+
def server_port
@env['SERVER_PORT'].to_i
end