From 1af6ed24650c84ebf85ce5f52eede28ae63f0ccd Mon Sep 17 00:00:00 2001 From: yqrashawn Date: Wed, 29 Nov 2023 11:50:49 +0800 Subject: [PATCH] fix: universal link regex fixes #17869 --- src/status_im2/constants.cljs | 3 ++- src/utils/universal_links_test.cljs | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/status_im2/constants.cljs b/src/status_im2/constants.cljs index cf315771f63a..c4b362b52f83 100644 --- a/src/status_im2/constants.cljs +++ b/src/status_im2/constants.cljs @@ -186,7 +186,8 @@ (def regx-bold #"\*[^*]+\*") (def regx-italic #"~[^~]+~") (def regx-backquote #"`[^`]+`") -(def regx-universal-link #"((^https?://status.app/)|(^status-app://))[\x00-\x7F]+$") +(def regx-universal-link + #"((^https?://status.app/)|(^status-app://))(c/|cc/|c#|u/|u#|p/|cr/|g/|wallet/)[\x00-\x7F]+$") (def regx-community-universal-link #"((^https?://status.app/)|(^status-app://))c/([\x00-\x7F]+)$") (def regx-deep-link #"((^ethereum:.*)|(^status-app://[\x00-\x7F]+$))") (def regx-ens #"^(?=.{5,255}$)([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.[a-zA-Z]{2,}$") diff --git a/src/utils/universal_links_test.cljs b/src/utils/universal_links_test.cljs index 64724a7e99fc..419373261708 100644 --- a/src/utils/universal_links_test.cljs +++ b/src/utils/universal_links_test.cljs @@ -5,8 +5,8 @@ (deftest universal-link-test (testing "status-app://blah" - (testing "it returns true" - (is (links/universal-link? "status-app://blah")))) + (testing "it returns false" + (is (not (links/universal-link? "status-app://blah"))))) (testing "status-app://blah" (testing "it returns true" (is (links/deep-link? "status-app://blah")))) @@ -14,11 +14,19 @@ (testing "it returns true" (is (links/deep-link? "ethereum:0x89205a3a3b2a69de6dbf7f01ed13b2108b2c43e7")))) (testing "http://status.app/blah" + (testing "it returns false" + (is (not (links/universal-link? "http://status.app/blah"))))) + (testing "http://status.app/c#zQ3shPyZJnxZK4Bwyx9QsaksNKDYTPmpwPvGSjMYVHoXHeEgB" (testing "it returns true" - (is (links/universal-link? "http://status.app/blah")))) - (testing "https://status.app/blah" + (is (links/universal-link? + "http://status.app/c#zQ3shPyZJnxZK4Bwyx9QsaksNKDYTPmpwPvGSjMYVHoXHeEgB")))) + (testing "http://status.app/u#zQ3shPyZJnxZK4Bwyx9QsaksNKDYTPmpwPvGSjMYVHoXHeEgB" (testing "it returns true" - (is (links/universal-link? "https://status.app/blah")))) + (is (links/universal-link? + "http://status.app/u#zQ3shPyZJnxZK4Bwyx9QsaksNKDYTPmpwPvGSjMYVHoXHeEgB")))) + (testing "https://status.app/blah" + (testing "it returns false" + (is (not (links/universal-link? "https://status.app/blah"))))) (testing "unicode characters" (testing "it returns false" (is (not (links/universal-link? "https://status.app/browse/www.аррӏе.com")))))