deprecated link resolution crash caught
This commit is contained in:
@@ -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
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user