Scheduling infrastructure for absolutely everyone.
chore: extended slugify function (#8740)
Ayush Mainali4b356dd937b9
diff --git a/packages/lib/slugify.ts b/packages/lib/slugify.tsindex c6fba1f4f08..70b51910433 100644--- a/packages/lib/slugify.ts+++ b/packages/lib/slugify.ts@@ -1,5 +1,13 @@export const slugify = (str: string) => {- return str.replace(/[^a-zA-Z0-9-]/g, "-").toLowerCase();+ return str+ .toLowerCase() // Convert to lowercase+ .trim() // Remove whitespace from both sides+ .normalize("NFD") // Normalize to decomposed form for handling accents+ .replace(/\p{Diacritic}/gu, "") // Remove any diacritics (accents) from characters+ .replace(/[^\p{L}\p{N}\p{Zs}\p{Emoji}]+/gu, "-") // Replace any non-alphanumeric characters (including Unicode) with a dash+ .replace(/[\s_]+/g, "-") // Replace whitespace and underscores with a single dash+ .replace(/^-+/, "") // Remove dashes from start+ .replace(/-+$/, ""); // Remove dashes from end};export default slugify;