// Mirrors the server helper in src/worker/auth/index.ts so rows with a // null `preferredUsername` display the same slug the OIDC claim emits. // When the column is set, it wins on both sides. Shared by the account // hub and /account/profile. export const fallbackHandle = (u: { name?: string | null; email: string }): string => { const slug = (s: string) => s .toLowerCase() .normalize("NFKD") .replace(/[^a-z0-9]+/g, "-") .replace(/^-+|-+$/g, ""); if (u.name?.trim()) { const fromName = slug(u.name); if (fromName) return fromName; } return slug(u.email.split("@")[0] ?? "") || "user"; };