[Fixes #7213] Properly handle universal links in status
Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
This commit is contained in:
parent
40aff1da8d
commit
13b6295469
|
@ -198,6 +198,17 @@
|
||||||
(when (and platform/android? (string/ends-with? url ".pdf"))
|
(when (and platform/android? (string/ends-with? url ".pdf"))
|
||||||
{:browser/show-web-browser-selection url}))
|
{:browser/show-web-browser-selection url}))
|
||||||
|
|
||||||
|
(fx/defn handle-message-link
|
||||||
|
[cofx link]
|
||||||
|
(if (utils.universal-links/universal-link? link)
|
||||||
|
(utils.universal-links/handle-url cofx link)
|
||||||
|
{:browser/show-browser-selection link}))
|
||||||
|
|
||||||
|
(fx/defn handle-universal-link
|
||||||
|
[cofx link]
|
||||||
|
(when (utils.universal-links/universal-link? link)
|
||||||
|
(utils.universal-links/handle-url cofx link)))
|
||||||
|
|
||||||
(fx/defn update-browser-on-nav-change
|
(fx/defn update-browser-on-nav-change
|
||||||
[cofx url error?]
|
[cofx url error?]
|
||||||
(let [browser (get-current-browser (:db cofx))
|
(let [browser (get-current-browser (:db cofx))
|
||||||
|
@ -209,6 +220,7 @@
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
(update-browser-history browser resolved-url)
|
(update-browser-history browser resolved-url)
|
||||||
(handle-pdf url)
|
(handle-pdf url)
|
||||||
|
(handle-universal-link url)
|
||||||
(resolve-url {:error? error? :resolved-url (when resolved-ens url)}))))))
|
(resolve-url {:error? error? :resolved-url (when resolved-ens url)}))))))
|
||||||
|
|
||||||
(fx/defn update-browser-name
|
(fx/defn update-browser-name
|
||||||
|
@ -335,12 +347,6 @@
|
||||||
(= type constants/api-request)
|
(= type constants/api-request)
|
||||||
(browser.permissions/process-permission cofx dapp-name permission messageId params))))
|
(browser.permissions/process-permission cofx dapp-name permission messageId params))))
|
||||||
|
|
||||||
(fx/defn handle-message-link
|
|
||||||
[cofx link]
|
|
||||||
(if (utils.universal-links/universal-link? link)
|
|
||||||
(utils.universal-links/handle-url cofx link)
|
|
||||||
{:browser/show-browser-selection link}))
|
|
||||||
|
|
||||||
(defn filter-letters-numbers-and-replace-dot-on-dash [value]
|
(defn filter-letters-numbers-and-replace-dot-on-dash [value]
|
||||||
(let [cc (.charCodeAt value 0)]
|
(let [cc (.charCodeAt value 0)]
|
||||||
(cond (or (and (> cc 96) (< cc 123))
|
(cond (or (and (> cc 96) (< cc 123))
|
||||||
|
|
|
@ -691,15 +691,21 @@
|
||||||
{:errors [{:type type :value value}]}))
|
{:errors [{:type type :value value}]}))
|
||||||
|
|
||||||
(def uri-prefix "https://get.status.im/extension/")
|
(def uri-prefix "https://get.status.im/extension/")
|
||||||
|
(def link-prefix "status-im://extension/")
|
||||||
|
|
||||||
(defn valid-uri? [s]
|
(defn valid-uri? [s]
|
||||||
(boolean
|
(boolean
|
||||||
(when s
|
(when s
|
||||||
(re-matches (re-pattern (str "^" uri-prefix "\\w+@.+")) (string/trim s)))))
|
(let [s' (string/trim s)]
|
||||||
|
(or
|
||||||
|
(re-matches (re-pattern (str "^" uri-prefix "\\w+@.+")) s')
|
||||||
|
(re-matches (re-pattern (str "^" link-prefix "\\w+@.+")) s'))))))
|
||||||
|
|
||||||
(defn url->uri [s]
|
(defn url->uri [s]
|
||||||
(when s
|
(when s
|
||||||
(string/replace s uri-prefix "")))
|
(-> s
|
||||||
|
(string/replace uri-prefix "")
|
||||||
|
(string/replace link-prefix ""))))
|
||||||
|
|
||||||
(defn load-from [url f]
|
(defn load-from [url f]
|
||||||
(when-let [uri (url->uri url)]
|
(when-let [uri (url->uri url)]
|
||||||
|
|
Loading…
Reference in New Issue