Skip to content

Node.js based forum software built for the modern web

moved islatin out too

Baris Soner Usakli74ccfd1e4d42
diff --git a/public/src/utils.js b/public/src/utils.js
index 40f74b26e1..bc97257382 100644
--- a/public/src/utils.js
+++ b/public/src/utils.js
@@ -106,18 +106,19 @@
collapseWhitespace : /\s+/g,
collapseDash : /-+/g,
trimTrailingDash : /-$/g,
+ isLatin : /^[\w]+$/,
//http://dense13.com/blog/2009/05/03/converting-string-to-slug-javascript/
slugify: function(str) {
str = str.replace(utils.trimRegex, '');
str = str.toLowerCase();
- if(/^[\w]+$/.test(str)) {
+ if(utils.isLatin.test(str)) {
str = str.replace(utils.invalidLatinChars, '-');
} else {
str = XRegExp.replace(str, utils.invalidUnicodeChars, '-');
}
- str = str.replace(utils.collapseWhitespace, '-') // collapse whitespace and replace by -
- str = str.replace(utils.collapseDash, '-'); // collapse dashes
+ str = str.replace(utils.collapseWhitespace, '-')
+ str = str.replace(utils.collapseDash, '-');
str = str.replace(utils.trimTrailingDash, '');
return str;
},