Skip to content

Instantly share code, notes, and snippets.

View sophieelsa's full-sized avatar
🌴
On vacation

Sophie Andriamahenintsoa sophieelsa

🌴
On vacation
View GitHub Profile
@sophieelsa
sophieelsa / slugify.js
Created May 14, 2019 09:59 — forked from merolhack/slugify.js
Javascript Slugify: For accents and other latin characters
function slugify(text)
{
var from = "ãàáäâẽèéëêìíïîõòóöôùúüûñç·/_,:;";
var to = "aaaaaeeeeeiiiiooooouuuunc------";
_.each( from, function( character, i ) {
text = text.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
});
return text
.toString() // Cast to string
.toLowerCase() // Convert the string to lowercase letters