support cyrilic in slug

This commit is contained in:
Sergey Kuleshov 2012-04-06 18:03:46 +03:00 committed by Mario Visic
parent 63c17313fb
commit ad9bd5f5f3

View File

@ -18,7 +18,7 @@
String.prototype.slugify = function(sep) { String.prototype.slugify = function(sep) {
if (typeof sep == 'undefined') sep = '_'; if (typeof sep == 'undefined') sep = '_';
var alphaNumRegexp = new RegExp('[^a-zA-Z0-9\\' + sep + ']', 'g'); var alphaNumRegexp = new RegExp('[^a-zA-Z0-9а-яА-Я\\' + sep + ']', 'g');
var avoidDuplicateRegexp = new RegExp('[\\' + sep + ']{2,}', '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()
} }