diff --git a/src/status_im/router/core.cljs b/src/status_im/router/core.cljs index d533f7f0d2ce..3ea8cff34077 100644 --- a/src/status_im/router/core.cljs +++ b/src/status_im/router/core.cljs @@ -43,15 +43,15 @@ (def routes ["" - {handled-schemes {["c/" :community-data] :community - ["cc/" :community-channel-id] :community-chat - ["p/" :chat-id] :private-chat - ["cr/" :community-id] :community-requests - "g/" group-chat-extractor - ["wallet/" :account] :wallet-account - ["u/" :user-data] :user - "c" :community - "u" :user} + {handled-schemes {["c/" :community-data] :community + ["cc/" :community-data] :community-chat + ["p/" :chat-id] :private-chat + ["cr/" :community-id] :community-requests + "g/" group-chat-extractor + ["wallet/" :account] :wallet-account + ["u/" :user-data] :user + "c" :community + "u" :user} ethereum-scheme eip-extractor}]) (defn parse-query-params @@ -68,7 +68,7 @@ (defn match-uri [uri] - (let [ ;; bidi has trouble parse path with `=` in it extract `=` here and add back to parsed + (let [;; bidi has trouble parse path with `=` in it extract `=` here and add back to parsed ;; base64url regex based on https://datatracker.ietf.org/doc/html/rfc4648#section-5 may ;; include invalid base64 (invalid length, length of any base64 encoded string must be a ;; multiple of 4) @@ -80,7 +80,7 @@ (if equal-end-of-base64url (string/replace-first uri equal-end-of-base64url "") uri) fragment (parse-fragment uri) - ens? (ens/is-valid-eth-name? fragment) + ens? (ens/is-valid-eth-name? fragment) {:keys [handler route-params] :as parsed} (assoc (bidi/match-route routes uri-without-equal-in-path) @@ -96,9 +96,19 @@ (and equal-end-of-base64url (= handler :community) (:community-data route-params)) (update-in [:route-params :community-data] #(str % equal-end-of-base64url)) - (and fragment (= handler :community-chat) (:community-channel-id route-params)) + (and equal-end-of-base64url (= handler :community-chat) (:community-data route-params)) + (update-in [:route-params :community-data] #(str % equal-end-of-base64url)) + + (and fragment (= handler :community-chat) (:community-data route-params)) (assoc-in [:route-params :community-id] fragment) + (and fragment + (= handler :community-chat) + (:community-data route-params) + (string? (:community-data route-params)) + (string/includes? (:community-data route-params) "-")) + (assoc-in [:route-params :community-channel-id] (:community-data route-params)) + (and equal-end-of-base64url (= handler :user) (:user-data route-params)) (update-in [:route-params :user-data] #(str % equal-end-of-base64url)) @@ -290,9 +300,13 @@ (cb {:type (community-route-type route-params) :community-id (:community-id route-params)}) - (= handler :community-chat) + (and (= handler :community-chat) (:community-channel-id route-params) (:community-id route-params)) (match-community-channel-async route-params cb) + (and (= handler :community-chat) (:community-id route-params)) + (cb {:type (community-route-type route-params) + :community-id (:community-id route-params)}) + ;; NOTE: removed in `match-uri`, might need this in the future (= handler :wallet-account) (cb (match-wallet-account route-params)) diff --git a/src/status_im/router/core_test.cljs b/src/status_im/router/core_test.cljs index f67f0124fbff..1922d2732a18 100644 --- a/src/status_im/router/core_test.cljs +++ b/src/status_im/router/core_test.cljs @@ -40,16 +40,32 @@ "https://status.app/cc/G54AAKwObLdpiGjXnckYzRcOSq0QQAS_CURGfqVU42ceGHCObstUIknTTZDOKF3E8y2MSicncpO7fTskXnoACiPKeejvjtLTGWNxUhlT7fyQS7Jrr33UVHluxv_PLjV2ePGw5GQ33innzeK34pInIgUGs5RjdQifMVmURalxxQKwiuoY5zwIjixWWRHqjHM=#zQ3shYSHp7GoiXaauJMnDcjwU2yNjdzpXLosAWapPS4CFxc11" [:community-chat - {:chat-data + {:community-data "G54AAKwObLdpiGjXnckYzRcOSq0QQAS_CURGfqVU42ceGHCObstUIknTTZDOKF3E8y2MSicncpO7fTskXnoACiPKeejvjtLTGWNxUhlT7fyQS7Jrr33UVHluxv_PLjV2ePGw5GQ33innzeK34pInIgUGs5RjdQifMVmURalxxQKwiuoY5zwIjixWWRHqjHM=" :community-id "zQ3shYSHp7GoiXaauJMnDcjwU2yNjdzpXLosAWapPS4CFxc11"}] "status-app://cc/G54AAKwObLdpiGjXnckYzRcOSq0QQAS_CURGfqVU42ceGHCObstUIknTTZDOKF3E8y2MSicncpO7fTskXnoACiPKeejvjtLTGWNxUhlT7fyQS7Jrr33UVHluxv_PLjV2ePGw5GQ33innzeK34pInIgUGs5RjdQifMVmURalxxQKwiuoY5zwIjixWWRHqjHM=#zQ3shYSHp7GoiXaauJMnDcjwU2yNjdzpXLosAWapPS4CFxc11" [:community-chat - {:chat-data + {:community-data "G54AAKwObLdpiGjXnckYzRcOSq0QQAS_CURGfqVU42ceGHCObstUIknTTZDOKF3E8y2MSicncpO7fTskXnoACiPKeejvjtLTGWNxUhlT7fyQS7Jrr33UVHluxv_PLjV2ePGw5GQ33innzeK34pInIgUGs5RjdQifMVmURalxxQKwiuoY5zwIjixWWRHqjHM=" :community-id "zQ3shYSHp7GoiXaauJMnDcjwU2yNjdzpXLosAWapPS4CFxc11"}] + "https://status.app/cc/c432709e-fc73-440d-bb67-cb3a0929dfda#zQ3shZL6dXiFCbDyxnXxwQa9v8QFC2q19subFtyxd7kVszMVo" + [:community-chat + {:community-data + "c432709e-fc73-440d-bb67-cb3a0929dfda" + :community-channel-id + "c432709e-fc73-440d-bb67-cb3a0929dfda" + :community-id "zQ3shZL6dXiFCbDyxnXxwQa9v8QFC2q19subFtyxd7kVszMVo"}] + + "status-app://cc/c432709e-fc73-440d-bb67-cb3a0929dfda#zQ3shZL6dXiFCbDyxnXxwQa9v8QFC2q19subFtyxd7kVszMVo" + [:community-chat + {:community-data + "c432709e-fc73-440d-bb67-cb3a0929dfda" + :community-channel-id + "c432709e-fc73-440d-bb67-cb3a0929dfda" + :community-id "zQ3shZL6dXiFCbDyxnXxwQa9v8QFC2q19subFtyxd7kVszMVo"}] + "https://status.app/c/iyKACkQKB0Rvb2RsZXMSJ0NvbG9yaW5nIHRoZSB3b3JsZCB3aXRoIGpveSDigKIg4bSXIOKAohiYohsiByMxMzFEMkYqAwEhMwM=#zQ3shYSHp7GoiXaauJMnDcjwU2yNjdzpXLosAWapPS4CFxc11" [:community {:community-data