From 9ea51d3295b19dfd4e4eaf79f9712c42e2d08d27 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Wed, 3 Jun 2020 12:02:29 +0200 Subject: [PATCH] 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. --- src/misc.erl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/misc.erl b/src/misc.erl index c91809015..2574c005a 100644 --- a/src/misc.erl +++ b/src/misc.erl @@ -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}.