diff options
author | Paweł Chmielowski <pawel@process-one.net> | 2021-12-06 15:46:52 +0100 |
---|---|---|
committer | Paweł Chmielowski <pawel@process-one.net> | 2021-12-06 15:46:52 +0100 |
commit | 8d8a3177e15aac8e693aa20e8e51d6463e81163d (patch) | |
tree | 07d6db0764283edb6b4455e0feb58d574dc43973 /src | |
parent | Add workaround for bug in older erlang version in rest module (diff) |
Eliminate xref warning from last commit
Diffstat (limited to 'src')
-rw-r--r-- | src/rest.erl | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/rest.erl b/src/rest.erl index 038ec1fb..1bb5c5ef 100644 --- a/src/rest.erl +++ b/src/rest.erl @@ -191,6 +191,18 @@ base_url(Server, Path) -> _ -> Url end. +-ifdef(HAVE_URI_STRING). +uri_hack(Str) -> + case uri_string:normalize("%25") of + "%" -> % This hack around bug in httpc >21 <23.2 + binary:replace(Str, <<"%25">>, <<"%2525">>, [global]); + _ -> Str + end. +-else. +uri_hack(Str) -> + Str. +-endif. + url(Url, []) -> Url; url(Url, Params) -> @@ -198,17 +210,7 @@ url(Url, Params) -> (misc:url_encode(Value))/binary>> || {Key, Value} <- Params], <<$&, Encoded0/binary>> = iolist_to_binary(L), - Encoded = - case erlang:function_exported(uri_string, normalize, 1) of - true -> - case uri_string:normalize("%25") of - "%" -> % This hack around bug in httpc >21 <23.2 - binary:replace(Encoded0, <<"%25">>, <<"%2525">>, [global]); - _ -> Encoded0 - end; - _ -> - Encoded0 - end, + Encoded = uri_hack(Encoded0), <<Url/binary, $?, Encoded/binary>>. url(Server, Path, Params) -> case binary:split(base_url(Server, Path), <<"?">>) of |