instance method
host_with_port
Ruby on Rails 8.1.2
Since v3.0.20Signature
host_with_port()
Returns a host:port string for this request, such as “example.com” or “example.com:8080”. Port is only included if it is not a default port (80 or 443)
req = ActionDispatch::Request.new 'HTTP_HOST' => 'example.com' req.host_with_port # => "example.com" req = ActionDispatch::Request.new 'HTTP_HOST' => 'example.com:80' req.host_with_port # => "example.com" req = ActionDispatch::Request.new 'HTTP_HOST' => 'example.com:8080' req.host_with_port # => "example.com:8080"
Source
# File actionpack/lib/action_dispatch/http/url.rb, line 340
def host_with_port
"#{host}#{port_string}"
end
Defined in actionpack/lib/action_dispatch/http/url.rb line 340
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionDispatch::Http::URL