From 6872d1a8578d727b430488f4c69b27104ab302e6 Mon Sep 17 00:00:00 2001 From: Sean Hagstrom Date: Tue, 16 Apr 2024 08:51:35 +0100 Subject: [PATCH] fix: do not throw exception when passing nil to utils.address/get-abbreviated-profile-url (#19593) --- src/utils/address.cljs | 2 +- src/utils/address_test.cljs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/utils/address.cljs b/src/utils/address.cljs index 6b51eb5b1e..f19f412b2f 100644 --- a/src/utils/address.cljs +++ b/src/utils/address.cljs @@ -46,7 +46,7 @@ with the 1st 5 characters of the encoded data followed by an ellipsis followed by the last 10 characters of the compressed public key" [universal-profile-url] - (when-let [re-find-result (re-find #"^https://(status.app/u/)(.*)#(.*)$" universal-profile-url)] + (when-let [re-find-result (re-find #"^https://(status.app/u/)(.*)#(.*)$" (str universal-profile-url))] (let [[_whole-url base-url encoded-data public-key] re-find-result] (when (> (count public-key) 9) (let [first-part-of-encoded-data (subs encoded-data 0 5) diff --git a/src/utils/address_test.cljs b/src/utils/address_test.cljs index 225143a12d..7fefd74a03 100644 --- a/src/utils/address_test.cljs +++ b/src/utils/address_test.cljs @@ -35,4 +35,7 @@ "https://status.app/uwu/abcdefg#zQ3shPrnUhhR42JJn3QdhodGest8w8MjiH8hPaimrdYpzeFUa")))) (testing "Ensure the function returns nil when given a public key shorter than 10 characters" - (is (nil? (utils.address/get-abbreviated-profile-url "https://status.app/u/abcdefg#012345678"))))) + (is (nil? (utils.address/get-abbreviated-profile-url "https://status.app/u/abcdefg#012345678")))) + + (testing "Ensure the function returns nil when given nil" + (is (nil? (utils.address/get-abbreviated-profile-url nil)))))