From 16a65c8ffc66ca0b368c144f61f9b56f885dda87 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Wed, 14 Oct 2015 16:00:45 -0400 Subject: [PATCH] closes #3754 --- public/src/utils.js | 6 ++++++ src/topics/create.js | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/public/src/utils.js b/public/src/utils.js index 930e03501f..a2f8ea7a80 100644 --- a/public/src/utils.js +++ b/public/src/utils.js @@ -381,6 +381,12 @@ }; } + if (typeof String.prototype.rtrim != 'function') { + String.prototype.rtrim = function() { + return this.replace(/\s+$/g, ''); + }; + } + if ('undefined' !== typeof window) { window.utils = module.exports; } diff --git a/src/topics/create.js b/src/topics/create.js index ae60a8c191..6ccc06de12 100644 --- a/src/topics/create.js +++ b/src/topics/create.js @@ -101,6 +101,9 @@ module.exports = function(Topics) { check(data.tags, meta.config.minimumTagsPerTopic, meta.config.maximumTagsPerTopic, 'not-enough-tags', 'too-many-tags', next); }, function(next) { + if (data.content) { + data.content = data.content.rtrim(); + } check(data.content, meta.config.minimumPostLength, meta.config.maximumPostLength, 'content-too-short', 'content-too-long', next); }, function(next) { @@ -228,7 +231,7 @@ module.exports = function(Topics) { function(filteredData, next) { content = filteredData.content || data.content; if (content) { - content = content.trim(); + content = content.rtrim(); } check(content, meta.config.minimumPostLength, meta.config.maximumPostLength, 'content-too-short', 'content-too-long', next);