]> cat aescling's git repositories - mastodon.git/commitdiff
Exclude URLs from text analysis (#11759)
authorMostafa Ahangarha <ahangarha@users.noreply.github.com>
Wed, 4 Sep 2019 20:30:49 +0000 (01:00 +0430)
committerEugen Rochko <eugen@zeonfederated.com>
Wed, 4 Sep 2019 20:30:49 +0000 (22:30 +0200)
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

index 00870a15d677b48498a70bd12f22fc6d745494b3..89bed6de88811a5be77b99fbee174c7276898f67 100644 (file)
@@ -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);