Compare exact string before checking variants

This commit is contained in:
Lim Chee Aun 2023-02-15 10:46:29 +08:00
parent 4c17522d42
commit f198571367

View file

@ -19,15 +19,16 @@ function NameText({
const displayNameWithEmoji = emojifyText(displayName, emojis);
const trimmedUsername = username.toLowerCase().trim();
const trimmedDisplayName = (displayName || '').toLowerCase().trim();
if (
!short &&
username.toLowerCase().trim() ===
(displayName || '')
(!short && trimmedUsername === trimmedDisplayName) ||
trimmedUsername ===
trimmedDisplayName
.replace(/(\:(\w|\+|\-)+\:)(?=|[\!\.\?]|$)/g, '') // Remove shortcodes, regex from https://regex101.com/r/iE9uV0/1
.replace(/\s+/g, '') // E.g. "My name" === "myname"
.replace(/[^a-z0-9]/gi, '') // Remove non-alphanumeric characters
.toLowerCase()
.trim()
) {
username = null;
}