summaryrefslogtreecommitdiff
path: root/lib/response.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/response.js')
-rw-r--r--lib/response.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/response.js b/lib/response.js
index 4cfa9a74..d1e5e15c 100644
--- a/lib/response.js
+++ b/lib/response.js
@@ -145,6 +145,8 @@ function responseHackMD (res, note) {
function newNote (req, res, next) {
var owner = null
+ var body = req.body ? req.body : ''
+ body = body.replace(/[\r]/g, '')
if (req.isAuthenticated()) {
owner = req.user.id
} else if (!config.allowAnonymous) {
@@ -153,7 +155,7 @@ function newNote (req, res, next) {
models.Note.create({
ownerId: owner,
alias: req.alias ? req.alias : null,
- content: req.body ? req.body : ''
+ content: body
}).then(function (note) {
return res.redirect(config.serverURL + '/' + models.Note.encodeNoteId(note.id))
}).catch(function (err) {
@@ -327,15 +329,18 @@ function actionInfo (req, res, note) {
}
function actionPDF (req, res, note) {
+ var url = config.serverURL || 'http://' + req.get('host')
var body = note.content
var extracted = models.Note.extractMeta(body)
+ var content = extracted.markdown
var title = models.Note.decodeTitle(note.title)
if (!fs.existsSync(config.tmpPath)) {
fs.mkdirSync(config.tmpPath)
}
var path = config.tmpPath + '/' + Date.now() + '.pdf'
- markdownpdf().from.string(extracted.markdown).to(path, function () {
+ content = content.replace(/\]\(\//g, '](' + url + '/')
+ markdownpdf().from.string(content).to(path, function () {
var stream = fs.createReadStream(path)
var filename = title
// Be careful of special characters