(name: string)
| 149 | * names, etc.) — callers fall back to a generated handle. |
| 150 | */ |
| 151 | export const slugifyOrgName = (name: string): string | null => { |
| 152 | const slug = name |
| 153 | .normalize("NFKD") |
| 154 | .replace(/\p{M}+/gu, "") |
| 155 | .toLowerCase() |
| 156 | .replace(/[^a-z0-9]+/g, "-") |
| 157 | .replace(/^-+|-+$/g, "") |
| 158 | .slice(0, 48) |
| 159 | .replace(/-+$/g, ""); |
| 160 | if (slug.length < 2 || !ORG_SLUG_PATTERN.test(slug)) return null; |
| 161 | return slug; |
| 162 | }; |
| 163 | |
| 164 | // Discriminator alphabet: lowercase base32 without the look-alikes (0/o, 1/l) |
| 165 | // so a slug read aloud or retyped from a screenshot survives the round trip. |
no test coverage detected