Add one more username ≈ display name logic

This commit is contained in:
Lim Chee Aun 2024-05-27 19:02:19 +08:00
parent 9aa2bac685
commit ef712c62a9

View file

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