Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/async/http/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ def scheme
# @returns [String] The authority component (hostname and optional port).
def authority(ignore_default_port = true)
if ignore_default_port and default_port?
@url.hostname
@url.host
else
"#{@url.hostname}:#{port}"
"#{@url.host}:#{port}"
end
end

Expand Down
12 changes: 12 additions & 0 deletions test/async/http/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@
end
end

with "#authority" do
it "keeps brackets around an IPv6 address" do
expect(Async::HTTP::Endpoint.parse("http://[::1]:8080")).to have_attributes(authority: be == "[::1]:8080")
expect(Async::HTTP::Endpoint.parse("http://[::1]")).to have_attributes(authority: be == "[::1]")
end

it "leaves hostnames and IPv4 addresses unchanged" do
expect(Async::HTTP::Endpoint.parse("http://localhost:8080")).to have_attributes(authority: be == "localhost:8080")
expect(Async::HTTP::Endpoint.parse("http://127.0.0.1")).to have_attributes(authority: be == "127.0.0.1")
end
end

with "#tls_configuration" do
let(:tls_configuration) do
IO::Endpoint::TLS::Configuration.new(verification: :none)
Expand Down
Loading