Merge commit from fork

This should not change the set of words matched by `USERNAME_RE` but does
change the one matched by `MENTION_RE`. Indeed, the previous regexp allowed
a domain part to start with `.` or `-`, which the new regexp does not allow.

Co-authored-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
David Roetzel 2024-09-30 12:25:54 +02:00 committed by GitHub
parent f9a929ed5c
commit 0e8f23ebee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -65,8 +65,8 @@ 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:]]+)?)}
USERNAME_RE = /[a-z0-9_]+([.-]+[a-z0-9_]+)*/i
MENTION_RE = %r{(?<![=/[:word:]])@((#{USERNAME_RE})(?:@[[:word:]]+([.-]+[[:word:]]+)*)?)}
URL_PREFIX_RE = %r{\Ahttp(s?)://[^/]+}
USERNAME_ONLY_RE = /\A#{USERNAME_RE}\z/i