fix post export crashing if a pid reference doesn't resolve to an actual post object

This commit is contained in:
Julian Lam
2018-05-22 14:45:39 -04:00
parent 01daf4b662
commit be1a977c71

View File

@@ -117,8 +117,8 @@ userController.exportPosts = function (req, res, next) {
return next(err);
}
// Convert newlines in content
posts = posts.map(function (post) {
// Remove empty post references and convert newlines in content
posts = posts.filter(Boolean).map(function (post) {
post.content = '"' + post.content.replace(/\n/g, '\\n').replace(/"/g, '\\"') + '"';
return post;
});