Skip to content

Commit

Permalink
Merge pull request #25 from ldgabbay/pr
Browse files Browse the repository at this point in the history
Update for deprecated http_uri:decode
  • Loading branch information
rmpalomino authored Jul 18, 2024
2 parents 179963e + b6c533f commit 144b476
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/lhttpc_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,17 @@ format_hdrs(Headers) ->
%% Internal functions
%%==============================================================================

% http_uri:decode was deprecated in OTP 23
-define(PCT_DECODE(X), http_uri:decode(X)).
-ifdef (OTP_RELEASE).
-if(?OTP_RELEASE >= 24).
% uri_string:percent_decode is actually available in OTP 23.2, but
% there is no way to conditionally compile based on OTP minor version.
-undef(PCT_DECODE).
-define(PCT_DECODE(X), uri_string:percent_decode(X)).
-endif.
-endif.

%%------------------------------------------------------------------------------
%% @private
%% @doc
Expand Down Expand Up @@ -243,10 +254,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 144b476

Please sign in to comment.