Skip to content

Commit

Permalink
fix: universal link regex
Browse files Browse the repository at this point in the history
fixes #17869
  • Loading branch information
yqrashawn committed Dec 1, 2023
1 parent b5202b4 commit 73249f5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/status_im2/constants.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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,}$")
Expand Down
18 changes: 13 additions & 5 deletions src/utils/universal_links_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,28 @@

(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"))))
(testing "ethereum:0x89205a3a3b2a69de6dbf7f01ed13b2108b2c43e7"
(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")))))
Expand Down

0 comments on commit 73249f5

Please sign in to comment.