fix(api): 🐛 Fix duplicated mentions, general refactorings

This commit is contained in:
Jesse Wierzbinski 2024-12-09 15:30:18 +01:00
parent 84a0a07ea6
commit e293bd280d
No known key found for this signature in database
5 changed files with 29 additions and 29 deletions

View file

@ -298,20 +298,17 @@ export const replaceTextMentions = (text: string, mentions: User[]): string => {
);
}
return finalText
.replace(
createRegExp(
return finalText.replace(
createRegExp(
exactly(
exactly(`@${username}`)
.notBefore(anyOf(letter, digit, charIn("@")))
.notAfter(anyOf(letter, digit, charIn("@"))),
[global],
),
linkTemplate(`@${username}@${baseHost}`),
)
.replaceAll(
`@${username}@${baseHost}`,
linkTemplate(`@${username}@${baseHost}`),
);
).or(exactly(`@${username}@${baseHost}`)),
[global],
),
linkTemplate(`@${username}@${baseHost}`),
);
}, text);
};