Browse Source

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
pull/4/head
Mostafa Ahangarha 4 years ago
committed by Eugen Rochko
parent
commit
e974d4923f
1 changed files with 1 additions and 0 deletions
  1. +1
    -0
      app/javascript/mastodon/rtl.js

+ 1
- 0
app/javascript/mastodon/rtl.js View 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);

Loading…
Cancel
Save