Skip to content

Commit 0c872be

Browse files
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.
1 parent e22eff8 commit 0c872be

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

app/models/account.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ class Account < ApplicationRecord
6868
DEFAULT_FIELDS_SIZE = 4
6969
INSTANCE_ACTOR_ID = -99
7070

71-
USERNAME_RE = /[a-z0-9_]+([a-z0-9_.-]+[a-z0-9_]+)?/i
72-
MENTION_RE = %r{(?<![=/[:word:]])@((#{USERNAME_RE})(?:@[[:word:].-]+[[:word:]]+)?)}
71+
USERNAME_RE = /[a-z0-9_]+([.-]+[a-z0-9_]+)*/i
72+
MENTION_RE = %r{(?<![=/[:word:]])@((#{USERNAME_RE})(?:@[[:word:]]+([.-]+[[:word:]]+)*)?)}
7373
URL_PREFIX_RE = %r{\Ahttp(s?)://[^/]+}
7474
USERNAME_ONLY_RE = /\A#{USERNAME_RE}\z/i
7575
USERNAME_LENGTH_LIMIT = 30

0 commit comments

Comments
 (0)