Skip to content

Node.js based forum software built for the modern web

fix: convert param to string in slugify

Barış Soner Uşaklı441dd86d2981
diff --git a/public/src/utils.js b/public/src/utils.js
index e3d76f0878..b647356308 100644
--- a/public/src/utils.js
+++ b/public/src/utils.js
@@ -351,7 +351,7 @@
if (!str) {
return '';
}
- str = str.replace(utils.trimRegex, '');
+ str = String(str).replace(utils.trimRegex, '');
if (utils.isLatin.test(str)) {
str = str.replace(utils.invalidLatinChars, '-');
} else {
diff --git a/test/utils.js b/test/utils.js
index 3d6e01606f..7ba317d0f2 100644
--- a/test/utils.js
+++ b/test/utils.js
@@ -46,6 +46,12 @@ describe('Utility Methods', function () {
done();
});
+ it('should work if a number is passed in', function (done) {
+ var slug = utils.slugify(12345);
+ assert.strictEqual(slug, '12345');
+ done();
+ });
+
describe('username validation', function () {
it('accepts latin-1 characters', function () {
var username = "John\"'-. Doeäâèéë1234";