Merge pull request #5661 from NodeBB/utils-rtrim

Deprecate non-standard `String.prototype.rtrim`
This commit is contained in:
Barış Soner Uşaklı
2017-05-09 16:44:43 -04:00
committed by GitHub
3 changed files with 17 additions and 8 deletions

View File

@@ -88,10 +88,6 @@ module.exports = function (Topics) {
], callback);
};
function rtrim(str) {
return str.replace(/\s+$/g, '');
}
Topics.post = function (data, callback) {
var uid = data.uid;
data.title = String(data.title).trim();
@@ -106,7 +102,7 @@ module.exports = function (Topics) {
},
function (next) {
if (data.content) {
data.content = rtrim(data.content);
data.content = utils.rtrim(data.content);
}
check(data.content, meta.config.minimumPostLength, meta.config.maximumPostLength, 'content-too-short', 'content-too-long', next);
},
@@ -239,7 +235,7 @@ module.exports = function (Topics) {
function (filteredData, next) {
content = filteredData.content || data.content;
if (content) {
content = rtrim(content);
content = utils.rtrim(content);
}
check(content, meta.config.minimumPostLength, meta.config.maximumPostLength, 'content-too-short', 'content-too-long', next);