Created
November 28, 2019 01:16
-
-
Save IgorHalfeld/6e19b6544313cf734304f03b702ccd62 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 = input => input | |
.toString() | |
.toLowerCase() | |
.replace(/[áãâà]/gi, 'a') | |
.replace(/[éê]/gi, 'e') | |
.replace(/í/gi, 'i') | |
.replace(/[óõô]/gi, 'o') | |
.replace(/ú/gi, 'u') | |
.replace(/ñ/gi, 'n') | |
.replace(/ç/g, 'c') | |
.replace(/[\s_]+/g, '-') | |
.replace(/[^\w-]+/g, '') | |
.replace(/-+/g, '-') | |
.replace(/^-+/, '') | |
.replace(/-+$/, ''); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment