Skip to content

Instantly share code, notes, and snippets.

@mi-ca
mi-ca / slugify.js
Created February 21, 2017 14:15 — forked from vincentorback/slugify.js
Slugify a string - javascript and php
/**
* Slugify a string
* @param {String} text
* @return {String}
*/
export function slugify(text) {
return text.toString().toLowerCase()
.replace(/([å,ä])/g, 'a') // Replace å and ä with aa
.replace(/(ö)/g, 'o') // Replace ö with o
.replace(/\s+/g, '-') // Replace spaces with -