mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
misc: Don't crash on URLs without port number
Let misc:uri_parse/1 return default HTTP(S) port number if the URL doesn't specify a port number, analogous to the behavior when USE_OLD_HTTP_URI is defined.
This commit is contained in:
parent
9ea51d3295
commit
945a5cd09c
10
src/misc.erl
10
src/misc.erl
@ -65,8 +65,14 @@ uri_parse(URL) ->
|
||||
uri_parse(URL) when is_binary(URL) ->
|
||||
uri_parse(binary_to_list(URL));
|
||||
uri_parse(URL) ->
|
||||
#{scheme:=Scheme,host:=Host,port:=Port,path:=Path} = uri_string:parse(URL),
|
||||
{ok, Scheme, Host, Port, Path}.
|
||||
case uri_string:parse(URL) of
|
||||
#{scheme := Scheme, host := Host, port := Port, path := Path} ->
|
||||
{ok, Scheme, Host, Port, Path};
|
||||
#{scheme := "https", host := Host, path := Path} ->
|
||||
{ok, "https", Host, 443, Path};
|
||||
#{scheme := "http", host := Host, path := Path} ->
|
||||
{ok, "http", Host, 80, Path}
|
||||
end.
|
||||
-endif.
|
||||
|
||||
-ifdef(USE_OLD_CRYPTO_HMAC).
|
||||
|
Loading…
Reference in New Issue
Block a user