diff --git a/src/metabase/util.clj b/src/metabase/util.clj index 081b13000d645dba7e05e9a12a52333ab5de6601..97f9ecc50ac1aad0abba2a5498c402adc2ba26d2 100644 --- a/src/metabase/util.clj +++ b/src/metabase/util.clj @@ -365,8 +365,9 @@ (when-let [^java.net.URL url (try (java.net.URL. string) (catch java.net.MalformedURLException _ nil))] - (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 + (when (and (.getProtocol url) (.getAuthority url)) + (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 "Timeout (in ms) for checking if a host is available with `host-up?` and `host-port-up?`." diff --git a/test/metabase/util_test.clj b/test/metabase/util_test.clj index 44821c9e11ac8b5968507f0e4bbe1357fde68376..f3b3b1d2d26fbe1d7863aa3815cf79c23433de52 100644 --- a/test/metabase/util_test.clj +++ b/test/metabase/util_test.clj @@ -113,7 +113,7 @@ (expect false (is-url? "http://metabasecom")) ; no period / TLD (expect false (is-url? "http://.com")) ; no domain (expect false (is-url? "http://google.")) ; no TLD - +(expect false (is-url? "http:/")) ; nil .getAuthority needs to be handled or NullPointerException ;;; ## tests for RPARTIAL