var slug = function(str) { str = str.replace(/^\s+|\s+$/g, ''); // trim str = str.toLowerCase(); // remove accents, swap ñ for n, etc var from = "ąãàáäâęẽèéëêìíïîõòóöôùúüûńñçćżźśł·/_,:;"; var to = "aaaaaaeeeeeeiiiiooooouuuunncczzsl------"; for (var i=0, l=from.length ; i