a51ba85253
Parse @username in comment content, notify mentioned users (dedup against recipe-author/parent-author who are already notified via comment/reply), and render @username as a link to their profile. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
12 lines
353 B
TypeScript
12 lines
353 B
TypeScript
const MENTION_REGEX = /@([a-z0-9_-]{3,30})/gi;
|
|
|
|
export function extractMentionedUsernames(content: string): string[] {
|
|
const matches = content.matchAll(MENTION_REGEX);
|
|
const usernames = new Set<string>();
|
|
for (const m of matches) {
|
|
const username = m[1];
|
|
if (username) usernames.add(username.toLowerCase());
|
|
}
|
|
return [...usernames];
|
|
}
|