|
43 | 43 |
|
44 | 44 | (def routes
|
45 | 45 | [""
|
46 |
| - {handled-schemes {["c/" :community-data] :community |
47 |
| - ["cc/" :community-channel-id] :community-chat |
48 |
| - ["p/" :chat-id] :private-chat |
49 |
| - ["cr/" :community-id] :community-requests |
50 |
| - "g/" group-chat-extractor |
51 |
| - ["wallet/" :account] :wallet-account |
52 |
| - ["u/" :user-data] :user |
53 |
| - "c" :community |
54 |
| - "u" :user} |
| 46 | + {handled-schemes {["c/" :community-data] :community |
| 47 | + ["cc/" :community-data] :community-chat |
| 48 | + ["p/" :chat-id] :private-chat |
| 49 | + ["cr/" :community-id] :community-requests |
| 50 | + "g/" group-chat-extractor |
| 51 | + ["wallet/" :account] :wallet-account |
| 52 | + ["u/" :user-data] :user |
| 53 | + "c" :community |
| 54 | + "u" :user} |
55 | 55 | ethereum-scheme eip-extractor}])
|
56 | 56 |
|
57 | 57 | (defn parse-query-params
|
|
68 | 68 |
|
69 | 69 | (defn match-uri
|
70 | 70 | [uri]
|
71 |
| - (let [ ;; bidi has trouble parse path with `=` in it extract `=` here and add back to parsed |
| 71 | + (let [;; bidi has trouble parse path with `=` in it extract `=` here and add back to parsed |
72 | 72 | ;; base64url regex based on https://datatracker.ietf.org/doc/html/rfc4648#section-5 may
|
73 | 73 | ;; include invalid base64 (invalid length, length of any base64 encoded string must be a
|
74 | 74 | ;; multiple of 4)
|
|
80 | 80 | (if equal-end-of-base64url (string/replace-first uri equal-end-of-base64url "") uri)
|
81 | 81 |
|
82 | 82 | fragment (parse-fragment uri)
|
83 |
| - ens? (ens/is-valid-eth-name? fragment) |
| 83 | + ens? (ens/is-valid-eth-name? fragment) |
84 | 84 |
|
85 | 85 | {:keys [handler route-params] :as parsed}
|
86 | 86 | (assoc (bidi/match-route routes uri-without-equal-in-path)
|
|
96 | 96 | (and equal-end-of-base64url (= handler :community) (:community-data route-params))
|
97 | 97 | (update-in [:route-params :community-data] #(str % equal-end-of-base64url))
|
98 | 98 |
|
99 |
| - (and fragment (= handler :community-chat) (:community-channel-id route-params)) |
| 99 | + (and equal-end-of-base64url (= handler :community-chat) (:community-data route-params)) |
| 100 | + (update-in [:route-params :community-data] #(str % equal-end-of-base64url)) |
| 101 | + |
| 102 | + (and fragment (= handler :community-chat) (:community-data route-params)) |
100 | 103 | (assoc-in [:route-params :community-id] fragment)
|
101 | 104 |
|
| 105 | + (and fragment |
| 106 | + (= handler :community-chat) |
| 107 | + (:community-data route-params) |
| 108 | + (string? (:community-data route-params)) |
| 109 | + (string/includes? (:community-data route-params) "-")) |
| 110 | + (assoc-in [:route-params :community-channel-id] (:community-data route-params)) |
| 111 | + |
102 | 112 | (and equal-end-of-base64url (= handler :user) (:user-data route-params))
|
103 | 113 | (update-in [:route-params :user-data] #(str % equal-end-of-base64url))
|
104 | 114 |
|
|
290 | 300 | (cb {:type (community-route-type route-params)
|
291 | 301 | :community-id (:community-id route-params)})
|
292 | 302 |
|
293 |
| - (= handler :community-chat) |
| 303 | + (and (= handler :community-chat) (:community-channel-id route-params) (:community-id route-params)) |
294 | 304 | (match-community-channel-async route-params cb)
|
295 | 305 |
|
| 306 | + (and (= handler :community-chat) (:community-id route-params)) |
| 307 | + (cb {:type (community-route-type route-params) |
| 308 | + :community-id (:community-id route-params)}) |
| 309 | + |
296 | 310 | ;; NOTE: removed in `match-uri`, might need this in the future
|
297 | 311 | (= handler :wallet-account)
|
298 | 312 | (cb (match-wallet-account route-params))
|
|
0 commit comments