25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-28 16:34:13 +01:00

Fix misc:try_url for erlang < R20

This commit is contained in:
Paweł Chmielowski 2018-06-29 11:13:16 +02:00
parent 46abf7cfab
commit 1fbb36c34a

View File

@ -223,7 +223,11 @@ try_read_file(Path) ->
%% Fails with `badarg` otherwise. The function is intended for usage %% Fails with `badarg` otherwise. The function is intended for usage
%% in configuration validators only. %% in configuration validators only.
-spec try_url(binary() | string()) -> binary(). -spec try_url(binary() | string()) -> binary().
try_url(URL) -> try_url(URL0) ->
URL = case URL0 of
V when is_binary(V) -> binary_to_list(V);
_ -> URL0
end,
case http_uri:parse(URL) of case http_uri:parse(URL) of
{ok, {Scheme, _, _, _, _, _}} when Scheme /= http, Scheme /= https -> {ok, {Scheme, _, _, _, _, _}} when Scheme /= http, Scheme /= https ->
?ERROR_MSG("Unsupported URI scheme: ~s", [URL]), ?ERROR_MSG("Unsupported URI scheme: ~s", [URL]),