Skip to content

Commit

Permalink
Switched from deprecated http_uri:decode to uri_string:percent_decode…
Browse files Browse the repository at this point in the history
… for OTP 24+
  • Loading branch information
ldgabbay committed Mar 19, 2022
1 parent 8e34985 commit 11d1c25
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/lhttpc_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,14 @@ format_hdrs(Headers) ->
%% Internal functions
%%==============================================================================

-define(PCT_DECODE(X), http_uri:decode(X)).
-ifdef (OTP_RELEASE).
-if(?OTP_RELEASE >= 24).
-undef(PCT_DECODE).
-define(PCT_DECODE(X), uri_string:percent_decode(X)).
-endif.
-endif.

%%------------------------------------------------------------------------------
%% @private
%% @doc
Expand Down Expand Up @@ -243,10 +251,10 @@ split_credentials(CredsHostPortPath) ->
case string:tokens(Creds, ":") of
[User] ->
% RFC1738 says ":password" is optional
{http_uri:decode(User), "",
{?PCT_DECODE(User), "",
string:join([HostPort | Path], "/")};
[User, Passwd] ->
{http_uri:decode(User), http_uri:decode(Passwd),
{?PCT_DECODE(User), ?PCT_DECODE(Passwd),
string:join([HostPort | Path], "/")}
end
end.
Expand Down

0 comments on commit 11d1c25

Please sign in to comment.