mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 14:35:47 +01:00
moved islatin out too
This commit is contained in:
@@ -106,18 +106,19 @@
|
|||||||
collapseWhitespace : /\s+/g,
|
collapseWhitespace : /\s+/g,
|
||||||
collapseDash : /-+/g,
|
collapseDash : /-+/g,
|
||||||
trimTrailingDash : /-$/g,
|
trimTrailingDash : /-$/g,
|
||||||
|
isLatin : /^[\w]+$/,
|
||||||
|
|
||||||
//http://dense13.com/blog/2009/05/03/converting-string-to-slug-javascript/
|
//http://dense13.com/blog/2009/05/03/converting-string-to-slug-javascript/
|
||||||
slugify: function(str) {
|
slugify: function(str) {
|
||||||
str = str.replace(utils.trimRegex, '');
|
str = str.replace(utils.trimRegex, '');
|
||||||
str = str.toLowerCase();
|
str = str.toLowerCase();
|
||||||
if(/^[\w]+$/.test(str)) {
|
if(utils.isLatin.test(str)) {
|
||||||
str = str.replace(utils.invalidLatinChars, '-');
|
str = str.replace(utils.invalidLatinChars, '-');
|
||||||
} else {
|
} else {
|
||||||
str = XRegExp.replace(str, utils.invalidUnicodeChars, '-');
|
str = XRegExp.replace(str, utils.invalidUnicodeChars, '-');
|
||||||
}
|
}
|
||||||
str = str.replace(utils.collapseWhitespace, '-') // collapse whitespace and replace by -
|
str = str.replace(utils.collapseWhitespace, '-')
|
||||||
str = str.replace(utils.collapseDash, '-'); // collapse dashes
|
str = str.replace(utils.collapseDash, '-');
|
||||||
str = str.replace(utils.trimTrailingDash, '');
|
str = str.replace(utils.trimTrailingDash, '');
|
||||||
return str;
|
return str;
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user