Revamp workspace archive handling with async support, input validation improvements and better session management
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
// Keep legacy printable names working, while excluding whitespace, controls,
|
||||
// path separators, and URL delimiters that are unsafe/confusing in identifiers.
|
||||
const USERNAME_PATTERN = /^[^\p{C}\s\\/@?#%]{3,64}$/u;
|
||||
|
||||
export function normalizeUsername(value) {
|
||||
return String(value || "").normalize("NFKC").trim();
|
||||
}
|
||||
|
||||
export function usernameError(username, label = "Username") {
|
||||
if (!username) return `${label} is required`;
|
||||
if (username.length < 3) return `${label} must be at least 3 characters`;
|
||||
if (username.length > 64) return `${label} must be at most 64 characters`;
|
||||
if (!USERNAME_PATTERN.test(username)) return `${label} may contain letters, numbers, dots, underscores, and hyphens only`;
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user