UNPKG

@better-auth-ui/core

Version:

Authentication components and data utilities for [Better Auth](https://better-auth.com), available for React and Solid.

13 lines (11 loc) 419 B
/** Generate a slug candidate. Creation checks availability before using it. */ export function generateOrganizationSlug(name: string, suffix?: string) { const slug = name .normalize("NFKD") .replace(/[\u0300-\u036f]/g, "") .toLowerCase() .replace(/[^a-z0-9]+/g, "-") .replace(/^-|-$/g, "") const candidate = slug || crypto.randomUUID() return suffix ? `${candidate}-${suffix}` : candidate }