Created
March 11, 2022 09:40
-
-
Save AitorAlejandro/faf9b98ae053a74af7863f6a1b0e33da to your computer and use it in GitHub Desktop.
Converts a string into a slugified string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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