Skip to content

Commit

Permalink
Exclude URLs from text analysis (mastodon#11759)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ahangarha authored and hiyuki2578 committed Oct 2, 2019
1 parent 5434f8f commit c790d88
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions app/javascript/mastodon/rtl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit c790d88

Please sign in to comment.