export function highlightUsers (text, userName, displayName) {
const findAnyMentionRegex = '@[\\w-]+(?:\\b)';
const atRegex = new RegExp(`${findAnyMentionRegex}`, 'gi');
const currentUser = [`@${userName}`, `@${displayName}`];
if (atRegex.test(text)) {
text = text.replace(atRegex, match => {
if (currentUser.includes(match)) {
return `${match}`;
}
return `${match}`;
});
}
return text;
}