Files
imen_pishghaman/apps/admin/src/utils/slug.ts
T

8 lines
224 B
TypeScript
Raw Normal View History

/** "Safety Shoes 2" → "safety-shoes-2" (Latin letters and digits only) */
export const toSlug = (text: string) =>
text
.toLowerCase()
.replace(/[^a-z0-9]+/g, "-")
.replace(/^-+|-+$/g, "")
.slice(0, 80);