Skip to content

Instantly share code, notes, and snippets.

@ndious
Last active December 11, 2015 02:09
Show Gist options
  • Save ndious/4528828 to your computer and use it in GitHub Desktop.
Save ndious/4528828 to your computer and use it in GitHub Desktop.
jQuery slugify function
(function ($) {
$.fn.slugify = function (value) {
var slug = value.toLowerCase();
slug = slug.replace(/\s|\W/g, '-');
slug = slug.replace(/[àáâãäå]/g, 'a');
slug = slug.replace('æ', 'ae');
slug = slug.replace('ç', 'c' );
slug = slug.replace(/[èéêë]/g, 'e');
slug = slug.replace(/[ìíîï]/g, 'i');
slug = slug.replace(/ñ/g, 'n');
slug = slug.replace(/[òóôõö]/g, 'o');
slug = slug.replace(/œ/g, 'oe');
slug = slug.replace(/[ùúûü]/g, 'u');
slug = slug.replace(/[ýÿ]/g, 'y');
return slug;
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment