Use TwitterText regex for valid domains in mentions

TwitterText already has a regex to check for valid domains that allows a
few domains the current Regex did not allow. Mainly it allows mentions
of accounts on domains with emoji in their domain names to be processed
correctly.

Mentions like `@test@🌈🌈🌈.st` will now work correctly.
This commit is contained in:
Mischa Holz 2023-07-10 21:38:00 +02:00
parent 61a0ec69fc
commit 51f47c54bf
No known key found for this signature in database
GPG Key ID: 15DCD33C0CAA67B2
1 changed files with 1 additions and 1 deletions

View File

@ -66,7 +66,7 @@ class Account < ApplicationRecord
BACKGROUND_REFRESH_INTERVAL = 1.week.freeze
USERNAME_RE = /[a-z0-9_]+([a-z0-9_.-]+[a-z0-9_]+)?/i
MENTION_RE = %r{(?<![=/[:word:]])@((#{USERNAME_RE})(?:@[[:word:].-]+[[:word:]]+)?)}i
MENTION_RE = %r{(?<![=/[:word:]])@((#{USERNAME_RE})(?:@#{Twitter::TwitterText::Regex[:valid_domain]})?)}i
URL_PREFIX_RE = %r{\Ahttp(s?)://[^/]+}
USERNAME_ONLY_RE = /\A#{USERNAME_RE}\z/i