End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
URI::HTTP#authority
authority
lib/uri/http.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.2.0/lib/uri/http.rb, line 97
def authority
if port == default_port
host
else
"#{host}:#{port}"
end
end
Description
Returns the authority for an HTTP uri, as defined in datatracker.ietf.org/doc/html/rfc3986/#section-3.2.
Example:
Example
URI::HTTP.build(host: 'www.example.com', path: '/foo/bar').authority #=> "www.example.com" URI::HTTP.build(host: 'www.example.com', port: 8000, path: '/foo/bar').authority #=> "www.example.com:8000" URI::HTTP.build(host: 'www.example.com', port: 80, path: '/foo/bar').authority #=> "www.example.com"