misc: Make sure uri_parse/1 returns strings

The uri_string:parse/1 function returns the URI elements as strings or
as binaries depending on the input.  Make sure misc:uri_parse/1 returns
strings in both cases, analogous to the behavior when USE_OLD_HTTP_URI
is defined.
This commit is contained in:
Holger Weiss 2020-06-03 12:02:29 +02:00
parent 77308e6aff
commit 9ea51d3295
1 changed files with 2 additions and 0 deletions

View File

@ -62,6 +62,8 @@ uri_parse(URL) ->
{ok, {Scheme, _UserInfo, Host, Port, Path, _Query}} = http_uri:parse(URL),
{ok, Scheme, Host, Port, Path}.
-else.
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}.