From 6899564a7625608edf3e40534c3c03075d76ddee 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 00870a15d6..89bed6de88 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);