diff options
author | Wu Cheng-Han | 2016-08-15 10:59:40 +0800 |
---|---|---|
committer | Wu Cheng-Han | 2016-08-15 10:59:40 +0800 |
commit | 9bf7b92707c7e0355332378fde42f987fdb3d26a (patch) | |
tree | 13cae443d4c608f72b93f01dc1e6b763b063d8e2 | |
parent | 3bcb36b46cb391ff30589caa3bbaca1fcf41483f (diff) |
Fix meta might be null issue
Diffstat (limited to '')
-rw-r--r-- | lib/models/note.js | 3 | ||||
-rw-r--r-- | lib/response.js | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/models/note.js b/lib/models/note.js index 3577d401..81013047 100644 --- a/lib/models/note.js +++ b/lib/models/note.js @@ -208,7 +208,8 @@ module.exports = function (sequelize, DataTypes) { } catch (err) { //na } - if (meta && meta.title && (typeof meta.title == "string" || typeof meta.title == "number")) { + if (!meta) meta = {}; + if (meta.title && (typeof meta.title == "string" || typeof meta.title == "number")) { title = meta.title; } else { var $ = cheerio.load(md.render(body)); diff --git a/lib/response.js b/lib/response.js index acd3c719..23818da8 100644 --- a/lib/response.js +++ b/lib/response.js @@ -108,6 +108,7 @@ function responseHackMD(res, note) { } catch(err) { //na } + if (!meta) meta = {}; var title = models.Note.decodeTitle(note.title); title = models.Note.generateWebTitle(meta.title || title); var template = config.hackmdpath; @@ -222,6 +223,7 @@ function showPublishNote(req, res, next) { } catch(err) { //na } + if (!meta) meta = {}; var createtime = note.createdAt; var updatetime = note.lastchangeAt; var text = S(body).escapeHTML().s; @@ -546,6 +548,7 @@ function showPublishSlide(req, res, next) { } catch(err) { //na } + if (!meta) meta = {}; var text = S(body).escapeHTML().s; var title = models.Note.decodeTitle(note.title); title = models.Note.generateWebTitle(meta.title || title); |