summaryrefslogtreecommitdiff
path: root/lib/response.js
diff options
context:
space:
mode:
authorChristoph (Sheogorath) Kern2018-06-24 01:57:26 +0200
committerGitHub2018-06-24 01:57:26 +0200
commitec78c4f2fc2eead9d7a4c0126172253f935a6e57 (patch)
tree661f7b04bc9d0a921317aa6fd13aa7c039ef1a1a /lib/response.js
parent050146e62cc9e1287db4a76fe6d8d5b8db776577 (diff)
parentf69e77de424ea763a87a04c9d66196d9353c8690 (diff)
Merge pull request #857 from hackmdio/fix/pdf-links
Fix broken images in PDF caused by misconfigred server URL
Diffstat (limited to 'lib/response.js')
-rw-r--r--lib/response.js5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/response.js b/lib/response.js
index 4cfa9a74..a3c988fc 100644
--- a/lib/response.js
+++ b/lib/response.js
@@ -327,15 +327,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