Skip to content

Commit

Permalink
Merge pull request #95 from danielwestendorf/fix-93
Browse files Browse the repository at this point in the history
Replace meta passed filename extension
  • Loading branch information
danielwestendorf authored Feb 22, 2020
2 parents d17bc84 + 93f81f4 commit 164f5f1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = class Render {
}

filename() {
return `${this.meta().filename || uuid()}.pdf`
return `${(this.meta().filename || uuid()).split('.')[0]}.pdf`
}

printOptions() {
Expand Down
16 changes: 15 additions & 1 deletion test/lib/render-test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const assert = require('assert')
let Render

const htmlString = `
let htmlString = `
<html>
<head>
<meta name='breezy-pdf-filename' content='fancyfilename'/>
Expand Down Expand Up @@ -48,6 +48,20 @@ module.exports = {

notSpecified() {
assert(new Render('').filename().match(/\.pdf$/))
},

alreadyHasExtension() {
htmlString = `
<html>
<head>
<meta name='breezy-pdf-filename' content='fancyfilename.pdf'/>
</head>
<body>
</body>
</html>
`.trim()

assert.equal('fancyfilename.pdf', new Render(htmlString).filename())
}
}
}

0 comments on commit 164f5f1

Please sign in to comment.