[#4073] Fix parse-url regexp

To not identify string like "test...test..." as an URL

Signed-off-by: Dmitry Novotochinov <dmitry.novot@gmail.com>
This commit is contained in:
Dmitry Novotochinov 2018-07-09 16:22:27 +03:00
parent 867488ae3c
commit bf9a291a09
No known key found for this signature in database
GPG Key ID: 43D1DAF5AD39C927
3 changed files with 9 additions and 2 deletions

View File

@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Fixed
- Fixed chat message layout for right-to-left languages
- Fixed parsing of messages containing multiple dots (elipsis)
## [0.9.22] - 2018-07-09
### Added

View File

@ -167,7 +167,7 @@
(def regx-styled (re-pattern (string/join "|" (map first replacements))))
(def regx-url #"(?i)(?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{1,4}/?)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'\".,<>?«»“”‘’]){0,}")
(def regx-url #"(?i)(?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9\-]+[.][a-z]{1,4}/?)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'\".,<>?«»“”‘’]){0,}")
(defn- parse-str-regx [string regx matched-fn unmatched-fn]
(if (string? string)

View File

@ -20,7 +20,13 @@
nil])
(message/parse-url "Status - https://github.com/status-im/status-react a Mobile Ethereum Operating System")))
(is (= (lazy-seq [{:text "Browse, chat and make payments securely on the decentralized web." :url? false} nil])
(message/parse-url "Browse, chat and make payments securely on the decentralized web."))))
(message/parse-url "Browse, chat and make payments securely on the decentralized web.")))
(is (= (lazy-seq [{:text "test...test..." :url? false} nil])
(message/parse-url "test...test...")))
(is (= (lazy-seq [{:text "test..test.." :url? false} nil])
(message/parse-url "test..test..")))
(is (= (lazy-seq [{:text "...test" :url? false} nil])
(message/parse-url "...test"))))
(deftest right-to-left-text?
(is (not (message/right-to-left-text? "You are lucky today!")))