Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = async options => {
}

if (options.data) {
newOptions.data = options.isFragment ? createDocument(options.data) : options.data
newOptions.data = options.isFragment ? createDocument(options.data, options.language ?? 'en') : options.data
newOptions.method = 'post'
if (!newOptions.headers['Content-Type']) {
newOptions.headers['Content-Type'] = 'text/html; charset=utf-8'
Expand Down
2 changes: 1 addition & 1 deletion lib/create-document-from-fragment.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = fragment => `<!DOCTYPE html><html lang="en"><head><title>Document from fragment</title></head><body>${fragment}</body></html>`
module.exports = (fragment, lang = 'en') => `<!DOCTYPE html><html lang="${lang}"><head><title>Document from fragment</title></head><body>${fragment}</body></html>`
2 changes: 1 addition & 1 deletion test/lib/create-document-from-fragment-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const createDocument = require('../../lib/create-document-from-fragment')

tap.test('returns document from fragment', test => {
const fragment = '<p>This is a fragment</p>'
const document = createDocument(fragment)
const document = createDocument(fragment, 'en')
const expectedDocument = '<!DOCTYPE html><html lang="en"><head><title>Document from fragment</title></head><body><p>This is a fragment</p></body></html>'
tap.equal(document, expectedDocument, 'document is correct')
test.end()
Expand Down