Update response to force note, publish note, publish slide redirect to their expected url
This commit is contained in:
parent
458d07dde7
commit
95c8f25fb5
1 changed files with 13 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue