Created
December 14, 2017 12:23
-
-
Save ancyrweb/4209bd3eafc403b375ef63332376e97d to your computer and use it in GitHub Desktop.
Slugify inspired by another gist
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
function slugify(text) { | |
return text.toString().toLowerCase() | |
.replace(/\s+/g, '-') | |
.replace(/[éèëê]/g, "e") | |
.replace(/[iïî]/g, "i") | |
.replace(/[àâ]/g, "a") | |
.replace(/[oôö]/g, "o") | |
.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