aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBadlop <badlop@process-one.net>2020-07-10 16:10:05 +0200
committerBadlop <badlop@process-one.net>2020-07-14 12:21:37 +0200
commite5b66aadaf4dcf833b357bb672948e1938a9acb0 (patch)
tree7168e37470cb15900ccc00c823bf8f7a17d96d0d
parentUpdate 'stun' dependency to tagged version (diff)
Fix try_url/1 parsing of uri_parse result format, reported by Dialyzer
-rw-r--r--src/misc.erl17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/misc.erl b/src/misc.erl
index 85d11da4a..6402e9419 100644
--- a/src/misc.erl
+++ b/src/misc.erl
@@ -357,18 +357,19 @@ try_url(URL0) ->
V when is_binary(V) -> binary_to_list(V);
_ -> URL0
end,
- case uri_parse(URL) of
- {ok, {Scheme, _, _, _, _, _}} when Scheme /= http, Scheme /= https ->
+ try uri_parse(URL) of
+ {ok, Scheme, _, _, _} when Scheme /= "http", Scheme /= "https" ->
?ERROR_MSG("Unsupported URI scheme: ~ts", [URL]),
erlang:error(badarg);
- {ok, {_, _, Host, _, _, _}} when Host == ""; Host == <<"">> ->
+ {ok, _, Host, _, _} when Host == ""; Host == <<"">> ->
?ERROR_MSG("Invalid URL: ~ts", [URL]),
erlang:error(badarg);
- {ok, _} ->
- iolist_to_binary(URL);
- {error, _} ->
- ?ERROR_MSG("Invalid URL: ~ts", [URL]),
- erlang:error(badarg)
+ {ok, _, _, _, _} ->
+ iolist_to_binary(URL)
+ catch
+ error:_ ->
+ ?ERROR_MSG("Invalid URL: ~ts", [URL]),
+ erlang:error(badarg)
end.
-spec css_dir() -> file:filename().