Skip to content

Commit 42875a9

Browse files
committed
fix idna error with IP addresses
spotted in #554: don't try to encode to IDNA an IP address.
1 parent 221dfae commit 42875a9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/hackney_connect.erl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ connect(Transport, Host, Port, Options, Dynamic) ->
3939

4040
Host2 = case Transport of
4141
hackney_local_tcp -> Host;
42-
_ -> idna:utf8_to_ascii(Host)
42+
_ ->
43+
case inet:parse_address(Host) of
44+
{ok, _} ->
45+
Host;
46+
_ ->
47+
idna:utf8_to_ascii(Host)
48+
end
4349
end,
4450

4551
case create_connection(Transport, Host2, Port, Options, Dynamic) of

0 commit comments

Comments
 (0)