Skip to content

Instantly share code, notes, and snippets.

@yaadspace
yaadspace / slug.js
Created August 22, 2012 19:32 — forked from jacoborus/slug.js
JS. Slug Generator - muy simple
// Generates a URL-friendly "slug" from a provided string.
// For example: "This Is Great!!!" transforms into "this-is-great"
// Aslo removes %20. For example: "This%20is%20great transforms into "this-is-great"
function generateSlug (value) {
// .1) removes %20 from string - most likely a url
var value = unescape(value) ;
// 1) convert to lowercase
// 2) remove dashes and pluses
// 3) replace spaces with dashes