add http:// to url [#3600]
Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
This commit is contained in:
parent
735a5b403d
commit
1752c5bc17
|
@ -4,7 +4,8 @@
|
|||
[status-im.ui.components.action-sheet :as action-sheet]
|
||||
[status-im.ui.components.dialog :as dialog]
|
||||
[status-im.ui.components.react :as react]
|
||||
[status-im.utils.platform :as platform]))
|
||||
[status-im.utils.platform :as platform]
|
||||
[status-im.utils.http :as http]))
|
||||
|
||||
(defn- open-share [content]
|
||||
(when (or (:message content)
|
||||
|
@ -32,5 +33,5 @@
|
|||
:options [{:label (i18n/label :t/browsing-open-in-browser)
|
||||
:action #(re-frame/dispatch [:open-browser {:url link}])}
|
||||
{:label (i18n/label :t/browsing-open-in-web-browser)
|
||||
:action #(.openURL react/linking link)}]
|
||||
:action #(.openURL react/linking (http/normalize-url link))}]
|
||||
:cancel-text (i18n/label :t/browsing-cancel)}))
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
[re-frame.core :as re-frame]
|
||||
[status-im.utils.random :as random]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.data-store.browser :as browser-store]))
|
||||
[status-im.data-store.browser :as browser-store]
|
||||
[status-im.utils.http :as http]))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:initialize-browsers
|
||||
|
@ -13,9 +14,6 @@
|
|||
(let [browsers (into {} (map #(vector (:browser-id %) %) all-stored-browsers))]
|
||||
{:db (assoc db :browser/browsers browsers)})))
|
||||
|
||||
(defn match-url [url]
|
||||
(str (when (and url (not (re-find #"^[a-zA-Z-_]+:/" url))) "http://") url))
|
||||
|
||||
(defn get-new-browser [browser now]
|
||||
(cond-> browser
|
||||
true
|
||||
|
@ -25,7 +23,7 @@
|
|||
(not (:name browser))
|
||||
(assoc :name (i18n/label :t/browser))
|
||||
(:url browser)
|
||||
(update :url match-url)))
|
||||
(update :url http/normalize-url)))
|
||||
|
||||
(defn add-browser-fx [{:keys [db now]} browser]
|
||||
(let [new-browser (get-new-browser browser now)]
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
(ns status-im.utils.http
|
||||
(:require [status-im.constants :as const]
|
||||
[status-im.utils.utils :as utils]
|
||||
(:require [status-im.utils.utils :as utils]
|
||||
[status-im.react-native.js-dependencies :as rn-dependencies])
|
||||
(:refer-clojure :exclude [get]))
|
||||
|
||||
|
@ -56,3 +55,6 @@
|
|||
(.catch (or on-error
|
||||
(fn [error]
|
||||
(utils/show-popup "Error" (str error))))))))
|
||||
|
||||
(defn normalize-url [url]
|
||||
(str (when (and url (not (re-find #"^[a-zA-Z-_]+:/" url))) "http://") url))
|
||||
|
|
Loading…
Reference in New Issue