[#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:
parent
867488ae3c
commit
bf9a291a09
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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!")))
|
||||
|
|
Loading…
Reference in New Issue