Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 14x | import { setup } from '../setup/internal'
import { USERNAME_BLOCKLIST } from './blocklist'
/**
* Check if a username is available.
*/
export async function isUsernameAvailable(
username: string
): Promise<boolean> {
const resp = await fetch(`${setup.endpoints.api}/user/data/${username}`)
return !resp.ok
}
/**
* Check if a username is valid.
*/
export function isUsernameValid(username: string): boolean {
return !username.startsWith("-") &&
!username.endsWith("-") &&
!username.startsWith("_") &&
/^[a-zA-Z1-9_-]+$/.test(username) &&
!USERNAME_BLOCKLIST.includes(username.toLowerCase())
}
|