Makes the forms check the same limits on what users submit as the server enforces, by holding them in one place.

Functions

f
localHandle(
handle: string,
isSelfHost: (host: string) => boolean
): string

Returns handle as this instance writes it, isSelfHost telling its own host. Another instance writes a user from here with this one's host, bob@gerbeur.example, who is bob here: a mention or a link copied from there names them so. Any other handle is returned as it is. The server resolves names by it (resolveUsername, the mention notifications), and the chat's highlight (mentionsUser) reads mentions by it.

f
splitHandle(handle: string): { name: string; host?: string; }

Returns the name and, for a user from another instance, the host of handle. splitHandle("alice@music.example") is { name: "alice", host: "music.example" }; a local name has no host.

Variables

v
DUMP_MAX_FILE_SIZE_BYTES: number

The largest file a file dump may hold, in bytes. dump-service refuses a bigger one, and the create form before uploading it.

v
EMAIL_RE: RegExp

Matches an email address well enough to catch a typo; only the reset email arriving proves it.

v
HANDLE_RE: RegExp

Matches a whole handle (HANDLE_SOURCE).

v
HANDLE_SOURCE: string

The pattern of a handle, the name a user goes by on this instance: a local user's username, or name@host for a user whose account lives on another gerbeur (federation-service.ts stores it so in users.username). Paths, mentions and the profile links all read names by it, through HANDLE_RE, MENTION_RE (shared/mention.ts) and parsePagePath (shared/paths.ts).

v
HOST_RE: RegExp

Matches a whole host (HOST_SOURCE).

v
HOST_SOURCE: string

The pattern of an instance's host as a handle writes it: DNS labels, and a port for instances on one machine (localhost:8001). It ends on a letter or a digit, so the period that ends a sentence after a mention isn't taken in. HANDLE_SOURCE builds on it.

v
RENAME_LIMITS: { SLUG: { count: number; windowMs: number; }; }

How often a dump's or a playlist's slug may change, counted from the aliases the changes left: 3 times a day. Moderators are exempt. slug-service refuses a change past it with a 429, and the edit forms say what the limit is.

v
USERNAME_RE: RegExp

Matches a valid username, made of letters, digits and underscores within the VALIDATION limits. Sign-up and renaming check it on both sides. It uses the same \w that a handle's pattern (HANDLE_SOURCE) reads a name with; only a user from another instance has the @host part.

v
UUID_RE: RegExp

Matches an id the server makes with crypto.randomUUID(). A route checks one before it names a file on disk, and shared/attachment.ts finds the attachments a text links by it.