deprecated link resolution crash caught

This commit is contained in:
Christian Müller
2015-10-18 18:49:03 +02:00
parent 664eb688ea
commit 929ab14a21
2 changed files with 3 additions and 4 deletions
+2 -3
View File
@@ -53,9 +53,8 @@ app.post('/note', function (req, res) {
});
app.get("/:year/:month/:day/:title", function (req, res) {
var P = req.params;
storage.getNoteId(P.year + "/" + P.month + "/" + P.day + "/" + P.title)
.then(id => res.redirect("/" + id));
var P = req.params, url = P.year + "/" + P.month + "/" + P.day + "/" + P.title;
storage.getNoteId(url).then(note => note ? res.redirect("/" + id) : notFound(res));
});
app.get(/\/([a-z0-9]+\/edit)/, function (req, res) {
+1 -1
View File
@@ -28,7 +28,7 @@ module.exports.getNoteId = deprecatedId => {
console.log("resolving deprecated Id", deprecatedId);
return Note.findOne({
where: { deprecatedId: deprecatedId }
}).then(note => note.id);
});
}
var generateId = () => [1, 1, 1, 1, 1]