[Fix #3604] ui, screens, browser, events: deduplicate browser history hence chat elements
This commit is contained in:
parent
0530f9c8dd
commit
48cc45ec6f
|
@ -73,10 +73,13 @@
|
||||||
:open-url-in-browser
|
:open-url-in-browser
|
||||||
[re-frame/trim-v]
|
[re-frame/trim-v]
|
||||||
(fn [cofx [url]]
|
(fn [cofx [url]]
|
||||||
(let [browser {:browser-id (random/id)
|
(let [normalized-url (http/normalize-and-decode-url url)
|
||||||
|
browser {:browser-id (or (http/url-host normalized-url)
|
||||||
|
;; purely as a fallback should url not parse...
|
||||||
|
(random/id))
|
||||||
:name (i18n/label :t/browser)
|
:name (i18n/label :t/browser)
|
||||||
:history-index 0
|
:history-index 0
|
||||||
:history [(http/normalize-and-decode-url url)]}]
|
:history [normalized-url]}]
|
||||||
(model/update-browser-and-navigate cofx browser))))
|
(model/update-browser-and-navigate cofx browser))))
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
(ns status-im.utils.http
|
(ns status-im.utils.http
|
||||||
(:require [status-im.utils.utils :as utils]
|
(:require [status-im.utils.utils :as utils]
|
||||||
[status-im.react-native.js-dependencies :as rn-dependencies]
|
[status-im.react-native.js-dependencies :as rn-dependencies]
|
||||||
[taoensso.timbre :as log])
|
[taoensso.timbre :as log]
|
||||||
|
[goog.Uri :as uri]
|
||||||
|
[clojure.string :as string])
|
||||||
(:refer-clojure :exclude [get]))
|
(:refer-clojure :exclude [get]))
|
||||||
|
|
||||||
;; Default HTTP request timeout ms
|
;; Default HTTP request timeout ms
|
||||||
|
@ -65,6 +67,13 @@
|
||||||
|
|
||||||
(def normalize-and-decode-url (comp js/decodeURI normalize-url))
|
(def normalize-and-decode-url (comp js/decodeURI normalize-url))
|
||||||
|
|
||||||
|
(defn url-host [url]
|
||||||
|
(try
|
||||||
|
(when-let [host (.getDomain (goog.Uri. url))]
|
||||||
|
(when-not (string/blank? host)
|
||||||
|
host))
|
||||||
|
(catch :default _ nil)))
|
||||||
|
|
||||||
(defn parse-payload [o]
|
(defn parse-payload [o]
|
||||||
(when o
|
(when o
|
||||||
(try
|
(try
|
||||||
|
|
|
@ -38,3 +38,18 @@
|
||||||
(testing "https://www.etheremon.com/assets/images/mons'><script>\\\\x3Bjavascript:alert(1)</script>origin/025.png"
|
(testing "https://www.etheremon.com/assets/images/mons'><script>\\\\x3Bjavascript:alert(1)</script>origin/025.png"
|
||||||
(testing "it returns false"
|
(testing "it returns false"
|
||||||
(is (not (http/url-sanitized? "https://www.etheremon.com/assets/images/mons'><script>\\\\x3Bjavascript:alert(1)</script>origin/025.png"))))))
|
(is (not (http/url-sanitized? "https://www.etheremon.com/assets/images/mons'><script>\\\\x3Bjavascript:alert(1)</script>origin/025.png"))))))
|
||||||
|
|
||||||
|
(deftest url-host-check
|
||||||
|
(testing "Extract host/domain from URL"
|
||||||
|
(testing "Valid URL with endpoint"
|
||||||
|
(is (= "status.im" (http/url-host "https://status.im/testing"))))
|
||||||
|
(testing "Valid URL"
|
||||||
|
(is (= "status.im" (http/url-host "http://status.im"))))
|
||||||
|
(testing "Blank domainlocalhost"
|
||||||
|
(is (nil? (http/url-host "localhost:3000/testing")))))
|
||||||
|
(testing "Return nil for Invalid URL"
|
||||||
|
(testing "Bad scheme"
|
||||||
|
(is (nil? (http/url-host "invalid//status.im/testing"))))
|
||||||
|
(testing "No scheme"
|
||||||
|
(is (nil? (http/url-host "status.im/testing"))))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue