From c790d88c7743decc522445c39f543551850493f4 Mon Sep 17 00:00:00 2001 From: Mostafa Ahangarha Date: Thu, 5 Sep 2019 01:00:49 +0430 Subject: [PATCH] Exclude URLs from text analysis (#11759) By the added regex, URLs, including the one without http or even www like mysite.com will be removed from the toot's body so only the real text of the toot will be analyzed for RTL detection --- app/javascript/mastodon/rtl.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/javascript/mastodon/rtl.js b/app/javascript/mastodon/rtl.js index 00870a15d677b4..89bed6de88811a 100644 --- a/app/javascript/mastodon/rtl.js +++ b/app/javascript/mastodon/rtl.js @@ -20,6 +20,7 @@ export function isRtl(text) { text = text.replace(/(?:^|[^\/\w])@([a-z0-9_]+(@[a-z0-9\.\-]+)?)/ig, ''); text = text.replace(/(?:^|[^\/\w])#([\S]+)/ig, ''); text = text.replace(/\s+/g, ''); + text = text.replace(/(\w\S+\.\w{2,}\S*)/g, ''); const matches = text.match(rtlChars);