mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 14:05:46 +01:00
last poster is visible, slugify check for latin #777
This commit is contained in:
@@ -99,17 +99,21 @@
|
||||
return difference + (min ? 'y' : ' year') + (difference !== 1 && !min ? 's' : '');
|
||||
},
|
||||
|
||||
invalidUnicodeChars : XRegExp('[^\\p{L}\\s\\d\\-_]', 'g'),
|
||||
invalidLatinChars : /[^\w\s\d\-_]/g,
|
||||
|
||||
//http://dense13.com/blog/2009/05/03/converting-string-to-slug-javascript/
|
||||
slugify: function(str) {
|
||||
var invalidChars = XRegExp('[^\\p{L}\\s\\d\\-_]', 'g');
|
||||
|
||||
str = str.replace(/^\s+|\s+$/g, ''); // trim
|
||||
str = str.toLowerCase();
|
||||
str = XRegExp.replace(str, invalidChars, '-');
|
||||
if(/^[\w]+$/.test(str)) {
|
||||
str = str.replace(utils.invalidLatinChars, '-');
|
||||
} else {
|
||||
str = XRegExp.replace(str, utils.invalidUnicodeChars, '-');
|
||||
}
|
||||
str = str.replace(/\s+/g, '-') // collapse whitespace and replace by -
|
||||
str = str.replace(/-+/g, '-'); // collapse dashes
|
||||
str = str.replace(/-$/g, '');
|
||||
|
||||
return str;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user