diff options
author | Wu Cheng-Han | 2016-10-10 20:38:14 +0800 |
---|---|---|
committer | Wu Cheng-Han | 2016-10-10 20:38:14 +0800 |
commit | 11a8c0f9cfbf9d94a5acc320991509660e5e74b2 (patch) | |
tree | 4278fa56c2842ee48fda96ffb31e30243e50b5ef | |
parent | 7e7919ce865771b884557e1f175e587491cb1abb (diff) |
Workaround cheerio text method shouldn't preserve html tags on fetching note title
Diffstat (limited to '')
-rw-r--r-- | lib/models/note.js | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/models/note.js b/lib/models/note.js index 17988f74..3478538f 100644 --- a/lib/models/note.js +++ b/lib/models/note.js @@ -13,6 +13,7 @@ var async = require('async'); var moment = require('moment'); var DiffMatchPatch = require('diff-match-patch'); var dmp = new DiffMatchPatch(); +var S = require('string'); // core var config = require("../config.js"); @@ -234,7 +235,7 @@ module.exports = function (sequelize, DataTypes) { var $ = cheerio.load(md.render(body)); var h1s = $("h1"); if (h1s.length > 0 && h1s.first().text().split('\n').length == 1) - title = h1s.first().text(); + title = S(h1s.first().text()).stripTags().s; } if (!title) title = "Untitled"; return title; |