Converts a string into a slugified string in TypeScript
Advertisements
const slugify = (str: string): string => str.toLowerCase().replace(/\s+/g, '-').replace(/[^\w-]+/g, ''); slugify('Hello World'); // -> hello-world