Skip to content

Instantly share code, notes, and snippets.

@ancyrweb
Created December 14, 2017 12:23
Show Gist options
  • Save ancyrweb/4209bd3eafc403b375ef63332376e97d to your computer and use it in GitHub Desktop.
Save ancyrweb/4209bd3eafc403b375ef63332376e97d to your computer and use it in GitHub Desktop.
Slugify inspired by another gist
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