aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaweł Chmielowski <pchmielowski@process-one.net>2018-06-29 11:13:16 +0200
committerPaweł Chmielowski <pchmielowski@process-one.net>2018-06-29 11:13:29 +0200
commit1fbb36c34aefcd835b2d742cfccebeabec674c59 (patch)
tree4a4a3a467ecc81fe0d08cf6d03f511a7f3b5d5b1 /src
parentRename obsolete type in comments (diff)
Fix misc:try_url for erlang < R20
Diffstat (limited to 'src')
-rw-r--r--src/misc.erl6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/misc.erl b/src/misc.erl
index 7aaebffc9..2e1b3f008 100644
--- a/src/misc.erl
+++ b/src/misc.erl
@@ -223,7 +223,11 @@ try_read_file(Path) ->
%% Fails with `badarg` otherwise. The function is intended for usage
%% in configuration validators only.
-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
{ok, {Scheme, _, _, _, _, _}} when Scheme /= http, Scheme /= https ->
?ERROR_MSG("Unsupported URI scheme: ~s", [URL]),