summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorWu Cheng-Han2016-07-02 16:11:30 +0800
committerWu Cheng-Han2016-07-02 16:11:30 +0800
commit95c8f25fb56b0e39c8c6734a9c9489e763999044 (patch)
treea3196cb36ad22fe937df2756a94d2459ce6c2f8b /lib
parent458d07dde7f8317f44a0f4d46b5b7d96d03ba9bd (diff)
Update response to force note, publish note, publish slide redirect to their expected url
Diffstat (limited to 'lib')
-rw-r--r--lib/response.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/response.js b/lib/response.js
index a04b7176..2fc5d58d 100644
--- a/lib/response.js
+++ b/lib/response.js
@@ -188,6 +188,11 @@ function findNote(req, res, callback, include) {
function showNote(req, res, next) {
findNote(req, res, function (note) {
+ // force to use note id
+ var noteId = req.params.noteId;
+ var id = LZString.compressToBase64(note.id);
+ if ((note.alias && noteId != note.alias) || (!note.alias && noteId != id))
+ return res.redirect(config.serverurl + "/" + (note.alias || id));
return responseHackMD(res, note);
});
}
@@ -201,6 +206,10 @@ function showPublishNote(req, res, next) {
as: "lastchangeuser"
}];
findNote(req, res, function (note) {
+ // force to use short id
+ var shortid = req.params.shortid;
+ if ((note.alias && shortid != note.alias) || (!note.alias && shortid != note.shortid))
+ return res.redirect(config.serverurl + "/s/" + (note.alias || note.shortid));
note.increment('viewcount').then(function (note) {
if (!note) {
return response.errorNotFound(res);
@@ -519,6 +528,10 @@ function gitlabActionProjects(req, res, note) {
function showPublishSlide(req, res, next) {
findNote(req, res, function (note) {
+ // force to use short id
+ var shortid = req.params.shortid;
+ if ((note.alias && shortid != note.alias) || (!note.alias && shortid != note.shortid))
+ return res.redirect(config.serverurl + "/p/" + (note.alias || note.shortid));
note.increment('viewcount').then(function (note) {
if (!note) {
return response.errorNotFound(res);