Use a better regex for mentions

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2024-05-29 00:30:26 +02:00
parent 02d1c5dcff
commit fff4077c73

View file

@ -357,7 +357,8 @@ const submitCompose = (composeId: string, opts: SubmitComposeOpts = {}) =>
return;
}
const mentions: string[] | null = status.match(/(?:^|\s)@([a-z\d_-]+(?:@[^@\s]+)?)/gi);
// https://stackoverflow.com/a/30007882 for domain regex
const mentions: string[] | null = status.match(/(?:^|\s)@([a-z\d_-]+(?:@(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]+)?)/gi);
if (mentions) {
to = to.union(mentions.map(mention => mention.trim().slice(1)));