Merge pull request #11 from RealJoesphStalin/stalin

More permissive usernames
This commit is contained in:
evanpelle
2025-02-09 20:34:18 -08:00
committed by GitHub
+4 -4
View File
@@ -11,9 +11,9 @@ const matcher = new RegExpMatcher({
});
export const MIN_USERNAME_LENGTH = 3;
export const MAX_USERNAME_LENGTH = 20;
export const MAX_USERNAME_LENGTH = 27;
const validPattern = /^[a-zA-Z0-9_\[\] ]+$/;
const validPattern = /^[a-zA-Z0-9_\[\] 🐈🍀]+$/;
const shadowNames = [
"NicePeopleOnly",
@@ -61,7 +61,7 @@ export function validateUsername(username: string): {
if (!validPattern.test(username)) {
return {
isValid: false,
error: "Username can only contain letters, numbers, and underscores.",
error: "Username can only contain letters, numbers, spaces, underscores, and [square brackets].",
};
}
@@ -71,7 +71,7 @@ export function validateUsername(username: string): {
export function sanitizeUsername(str: string): string {
const sanitized = str
.replace(/[^a-zA-Z0-9]/g, "")
.replace(/[^a-zA-Z0-9_\[\] 🐈🍀]/g, "")
.slice(0, MAX_USERNAME_LENGTH);
return sanitized.padEnd(MIN_USERNAME_LENGTH, "x");
}