Fix commas breaking contributor mentions

This commit is contained in:
Tarrgon
2025-08-13 11:42:53 -04:00
parent 986b7ead9e
commit f7b2f28540
+4 -3
View File
@@ -1,12 +1,13 @@
import { Database } from '../shared/Database';
const mentionRegex = new RegExp('@([\\S]+)', 'gi');
const mentionRegex = new RegExp('@([\\S]+),|@([\\S]+)', 'gi');
export async function fixPings(body: string): Promise<string> {
const mappings = await Database.getAllGithubUserMappings();
return body.replaceAll(mentionRegex, (match, username) => {
const mapping = mappings.find(m => m.github_username == username);
return body.replaceAll(mentionRegex, (match, m1, m2) => {
const name = m1 ?? m2;
const mapping = mappings.find(m => m.github_username == name);
return mapping ? `<@${mapping.discord_id}>` : match;
});