module ActionDispatch::Http::URL
def optional_port
req = ActionDispatch::Request.new 'HTTP_HOST' => 'example.com:8080'
req.optional_port # => nil
req = ActionDispatch::Request.new 'HTTP_HOST' => 'example.com:80'
is not the default HTTP \port 80 or HTTPS \port 443.
Returns a number \port suffix like 8080 if the \port number of this request
def optional_port standard_port? ? nil : port end