Skip to content

Commit 668d590

Browse files
committed
update topic for slug empty issue.
1 parent d62f9a8 commit 668d590

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

controllers/topic.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ exports.edit = function (req, res, next) {
553553
}
554554
if (topic.author_id.toString() === req.session.user._id.toString() || req.session.user.is_admin) {
555555
var title = sanitize(req.body.title).trim();
556-
var slug = sanitize(req.body.slug).trim();
556+
var slug = req.body.slug ? sanitize(req.body.slug).trim() : '';
557557
var content;
558558
var topic_tags;
559559
var announcement;
@@ -594,7 +594,7 @@ exports.edit = function (req, res, next) {
594594
topic.content = content;
595595
topic.update_at = new Date();
596596
topic.announcement = announcement;
597-
topic.slug = slug || topic._id;
597+
topic.slug = (slug === '') ? topic._id : slug;
598598

599599
topic.save(function (err) {
600600
if (err) {

0 commit comments

Comments
 (0)