From 7897c3d0e170495615d40152df9dbddb8df5d2df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chmielowski?= Date: Mon, 6 Dec 2021 15:07:59 +0100 Subject: [PATCH] Add workaround for bug in older erlang version in rest module --- src/rest.erl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/rest.erl b/src/rest.erl index d724352f2..038ec1fb1 100644 --- a/src/rest.erl +++ b/src/rest.erl @@ -197,7 +197,18 @@ url(Url, Params) -> L = [<<"&", (iolist_to_binary(Key))/binary, "=", (misc:url_encode(Value))/binary>> || {Key, Value} <- Params], - <<$&, Encoded/binary>> = iolist_to_binary(L), + <<$&, 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, <>. url(Server, Path, Params) -> case binary:split(base_url(Server, Path), <<"?">>) of