fix: do not throw exception when passing nil to utils.address/get-abbreviated-profile-url (#19593)

This commit is contained in:
Sean Hagstrom 2024-04-16 08:51:35 +01:00 committed by GitHub
parent 98d4969ca5
commit 6872d1a857
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View File

@ -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)

View File

@ -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)))))