From db615e511195adcc224e3c3668e0d993dd441dc6 Mon Sep 17 00:00:00 2001 From: BoHong Li Date: Wed, 26 Feb 2020 10:23:46 +0800 Subject: [PATCH] fix: page broken when shortId doesn't exists Signed-off-by: BoHong Li --- lib/note/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/note/index.js b/lib/note/index.js index 47698204..d90371fe 100644 --- a/lib/note/index.js +++ b/lib/note/index.js @@ -94,14 +94,14 @@ async function showPublishNote (req, res) { includeUser: true }) - if (!canViewNote(note, req.isAuthenticated(), req.user ? req.user.id : null)) { - return errorForbidden(req) - } - if (!note) { return errorNotFound(res) } + if (!canViewNote(note, req.isAuthenticated(), req.user ? req.user.id : null)) { + return errorForbidden(req) + } + if ((note.alias && shortid !== note.alias) || (!note.alias && shortid !== note.shortid)) { return res.redirect(config.serverURL + '/s/' + (note.alias || note.shortid)) }