Skip to content

Instantly share code, notes, and snippets.


Eduardo Vieira edgvi10

  • Amora Sistemas, Link Informática RJ
  • Rio de Janeiro
View GitHub Profile
edgvi10 / slugify.js
Last active Aug 25, 2020 — forked from codeguy/slugify.js
Create slug from string in Javascript
View slugify.js
String.prototype.slugify = function (separator = "-") {
return this
.normalize('NFD') // split an accented letter in the base letter and the acent
.replace(/[\u0300-\u036f]/g, '') // remove all previously split accents
.replace(/[^a-z0-9 ]/g, '') // remove all chars not letters, numbers and spaces (to be replaced)
.replace(/\s+/g, separator);