Skip to content

Instantly share code, notes, and snippets.

@AitorAlejandro
Created March 11, 2022 09:40
Show Gist options
  • Save AitorAlejandro/faf9b98ae053a74af7863f6a1b0e33da to your computer and use it in GitHub Desktop.
Save AitorAlejandro/faf9b98ae053a74af7863f6a1b0e33da to your computer and use it in GitHub Desktop.
Converts a string into a slugified string
const slugify = (str: string): string => str.toLowerCase().replace(/\s+/g, '-').replace(/[^\w-]+/g, '');
slugify('Hello World'); // -> hello-world
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment