aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2020-06-03 12:22:14 +0200
committerHolger Weiss <holger@zedat.fu-berlin.de>2020-06-03 12:22:14 +0200
commit945a5cd09cf055a3acd08db8aebce11e8f88fe29 (patch)
tree94c77b0690873c450e2e8fff596c5384a8e31e86 /src
parentmisc: Make sure uri_parse/1 returns strings (diff)
misc: Don't crash on URLs without port number
Let misc:uri_parse/1 return default HTTP(S) port number if the URL doesn't specify a port number, analogous to the behavior when USE_OLD_HTTP_URI is defined.
Diffstat (limited to 'src')
-rw-r--r--src/misc.erl10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/misc.erl b/src/misc.erl
index 2574c005a..85d11da4a 100644
--- a/src/misc.erl
+++ b/src/misc.erl
@@ -65,8 +65,14 @@ uri_parse(URL) ->
uri_parse(URL) when is_binary(URL) ->
uri_parse(binary_to_list(URL));
uri_parse(URL) ->
- #{scheme:=Scheme,host:=Host,port:=Port,path:=Path} = uri_string:parse(URL),
- {ok, Scheme, Host, Port, Path}.
+ case uri_string:parse(URL) of
+ #{scheme := Scheme, host := Host, port := Port, path := Path} ->
+ {ok, Scheme, Host, Port, Path};
+ #{scheme := "https", host := Host, path := Path} ->
+ {ok, "https", Host, 443, Path};
+ #{scheme := "http", host := Host, path := Path} ->
+ {ok, "http", Host, 80, Path}
+ end.
-endif.
-ifdef(USE_OLD_CRYPTO_HMAC).