From fff4077c73ecbc1c51bd4fc428fee8e5db2791c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Wed, 29 May 2024 00:30:26 +0200 Subject: [PATCH] Use a better regex for mentions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- src/actions/compose.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/actions/compose.ts b/src/actions/compose.ts index 601a813f1f..98ae75d3de 100644 --- a/src/actions/compose.ts +++ b/src/actions/compose.ts @@ -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)));