Skip to content
Snippets Groups Projects
Commit 35d025d7 authored by Allen Gilliland's avatar Allen Gilliland
Browse files

fix potential NullPointer caused when .getAuthority or .getProtocol is null on a valid url.

parent b823cacc
No related branches found
No related tags found
No related merge requests found
...@@ -365,8 +365,9 @@ ...@@ -365,8 +365,9 @@
(when-let [^java.net.URL url (try (java.net.URL. string) (when-let [^java.net.URL url (try (java.net.URL. string)
(catch java.net.MalformedURLException _ (catch java.net.MalformedURLException _
nil))] nil))]
(and (re-matches #"^https?$" (.getProtocol url)) ; these are both automatically downcased (when (and (.getProtocol url) (.getAuthority url))
(re-matches #"^.+\..{2,}$" (.getAuthority url))))))) ; this is the part like 'google.com'. Make sure it contains at least one period and 2+ letter TLD (and (re-matches #"^https?$" (.getProtocol url)) ; these are both automatically downcased
(re-matches #"^.+\..{2,}$" (.getAuthority url)))))))) ; this is the part like 'google.com'. Make sure it contains at least one period and 2+ letter TLD
(def ^:private ^:const host-up-timeout (def ^:private ^:const host-up-timeout
"Timeout (in ms) for checking if a host is available with `host-up?` and `host-port-up?`." "Timeout (in ms) for checking if a host is available with `host-up?` and `host-port-up?`."
......
...@@ -113,7 +113,7 @@ ...@@ -113,7 +113,7 @@
(expect false (is-url? "http://metabasecom")) ; no period / TLD (expect false (is-url? "http://metabasecom")) ; no period / TLD
(expect false (is-url? "http://.com")) ; no domain (expect false (is-url? "http://.com")) ; no domain
(expect false (is-url? "http://google.")) ; no TLD (expect false (is-url? "http://google.")) ; no TLD
(expect false (is-url? "http:/")) ; nil .getAuthority needs to be handled or NullPointerException
;;; ## tests for RPARTIAL ;;; ## tests for RPARTIAL
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment