repair the js slugify method

This commit is contained in:
Didier Lafforgue 2012-04-13 18:08:53 +02:00
parent 9dc3f778a4
commit a507d756b7

View File

@ -18,9 +18,9 @@
String.prototype.slugify = function(sep) {
if (typeof sep == 'undefined') sep = '_';
var alphaNumRegexp = new RegExp('[^\w\\' + sep + ']', 'g');
var alphaNumRegexp = new RegExp('[^\\w\\' + sep + ']', 'g');
var avoidDuplicateRegexp = new RegExp('[\\' + sep + ']{2,}', 'g');
return this.replace(/\s/g, sep).replace(alphaNumRegexp, '').replace(avoidDuplicateRegexp, sep).toLowerCase()
return this.replace(/\s/g, sep).replace(alphaNumRegexp, '').replace(avoidDuplicateRegexp, sep).toLowerCase();
}
window.addParameterToURL = function(key, value, context) { // code from http://stackoverflow.com/questions/486896/adding-a-parameter-to-the-url-with-javascript