instance method
optional_port
Ruby on Rails 7.2.3
Since v3.1.12Signature
optional_port()
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.
req = ActionDispatch::Request.new 'HTTP_HOST' => 'example.com:80' req.optional_port # => nil req = ActionDispatch::Request.new 'HTTP_HOST' => 'example.com:8080' req.optional_port # => 8080
Source
# File actionpack/lib/action_dispatch/http/url.rb, line 294
def optional_port
standard_port? ? nil : port
end
Defined in actionpack/lib/action_dispatch/http/url.rb line 294
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionDispatch::Http::URL