File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -158,9 +158,9 @@ def scheme
158158 # @returns [String] The authority component (hostname and optional port).
159159 def authority ( ignore_default_port = true )
160160 if ignore_default_port and default_port?
161- @url . hostname
161+ @url . host
162162 else
163- "#{ @url . hostname } :#{ port } "
163+ "#{ @url . host } :#{ port } "
164164 end
165165 end
166166
Original file line number Diff line number Diff line change 5757 end
5858 end
5959
60+ with "#authority" do
61+ it "keeps brackets around an IPv6 address" do
62+ expect ( Async ::HTTP ::Endpoint . parse ( "http://[::1]:8080" ) ) . to have_attributes ( authority : be == "[::1]:8080" )
63+ expect ( Async ::HTTP ::Endpoint . parse ( "http://[::1]" ) ) . to have_attributes ( authority : be == "[::1]" )
64+ end
65+
66+ it "keeps brackets around an IPv6 address when including the default port" do
67+ expect ( Async ::HTTP ::Endpoint . parse ( "http://[::1]" ) . authority ( false ) ) . to be == "[::1]:80"
68+ end
69+
70+ it "leaves hostnames and IPv4 addresses unchanged" do
71+ expect ( Async ::HTTP ::Endpoint . parse ( "http://localhost:8080" ) ) . to have_attributes ( authority : be == "localhost:8080" )
72+ expect ( Async ::HTTP ::Endpoint . parse ( "http://127.0.0.1" ) ) . to have_attributes ( authority : be == "127.0.0.1" )
73+ end
74+ end
75+
6076 with "#tls_configuration" do
6177 let ( :tls_configuration ) do
6278 IO ::Endpoint ::TLS ::Configuration . new ( verification : :none )
You can’t perform that action at this time.
0 commit comments