dokploy/lib/slug.ts
2024-06-08 16:41:46 -06:00

16 lines
262 B
TypeScript

import slug from "slugify";
export const slugify = (text: string | undefined) => {
if (!text) {
return "";
}
const cleanedText = text.trim().replace(/[^a-zA-Z0-9\s]/g, "");
return slug(cleanedText, {
lower: true,
trim: true,
strict: true,
});
};