Skip to content

Commit 95c8f25

Browse files
committed
Update response to force note, publish note, publish slide redirect to their expected url
1 parent 458d07d commit 95c8f25

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

lib/response.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ function findNote(req, res, callback, include) {
188188

189189
function showNote(req, res, next) {
190190
findNote(req, res, function (note) {
191+
// force to use note id
192+
var noteId = req.params.noteId;
193+
var id = LZString.compressToBase64(note.id);
194+
if ((note.alias && noteId != note.alias) || (!note.alias && noteId != id))
195+
return res.redirect(config.serverurl + "/" + (note.alias || id));
191196
return responseHackMD(res, note);
192197
});
193198
}
@@ -201,6 +206,10 @@ function showPublishNote(req, res, next) {
201206
as: "lastchangeuser"
202207
}];
203208
findNote(req, res, function (note) {
209+
// force to use short id
210+
var shortid = req.params.shortid;
211+
if ((note.alias && shortid != note.alias) || (!note.alias && shortid != note.shortid))
212+
return res.redirect(config.serverurl + "/s/" + (note.alias || note.shortid));
204213
note.increment('viewcount').then(function (note) {
205214
if (!note) {
206215
return response.errorNotFound(res);
@@ -519,6 +528,10 @@ function gitlabActionProjects(req, res, note) {
519528

520529
function showPublishSlide(req, res, next) {
521530
findNote(req, res, function (note) {
531+
// force to use short id
532+
var shortid = req.params.shortid;
533+
if ((note.alias && shortid != note.alias) || (!note.alias && shortid != note.shortid))
534+
return res.redirect(config.serverurl + "/p/" + (note.alias || note.shortid));
522535
note.increment('viewcount').then(function (note) {
523536
if (!note) {
524537
return response.errorNotFound(res);

0 commit comments

Comments
 (0)