Skip to content

Commit

Permalink
Gzip .svgz file
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoColomb committed Feb 11, 2019
1 parent bfe5b16 commit c8d1661
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions bin/generate-fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,32 @@ const errorCb = (err) => {

for (const suite of testSuites) {
for (const request of Object.keys(suite.requests)) {
let content = {}
const type = mime.contentType(request)
content = Object.assign(content, {
let content = {
'Content-Type': type || null,
'Content-Encoding': compressible(type) ? 'gzip' : null
})
}
if (suite.default && suite.default.responseHeaders) {
content = Object.assign(content, suite.default.responseHeaders)
}
if (suite.requests[request].responseHeaders) {
content = Object.assign(content, suite.requests[request].responseHeaders)
}
fs.outputFile(`fixtures/${request}`, JSON.stringify(content), errorCb)
fs.outputJsonSync(`fixtures/${request}`, content)
}
}

fs.outputFile('fixtures/test.svgz', zlib.gzipSync(fs.readFileSync('fixtures/test.svgz')), errorCb)

for (const folder of ['/', '.well-known/', '.well-known/test/']) {
fs.outputFile(`fixtures/${folder}.hidden_directory/test.html`, '', (err) => {
if (err) throw err
})
fs.outputFile(`fixtures/${folder}.hidden_directory/test.html`, '', errorCb)
}

fs.outputFile(`fixtures/test-pre-gzip.js.gz`, zlib.gzipSync(JSON.stringify({
fs.outputFile('fixtures/test-pre-gzip.js.gz', zlib.gzipSync(JSON.stringify({
'Content-Type': 'text/javascript; charset=utf-8',
'Content-Encoding': 'gzip'
})), errorCb)
fs.outputFile(`fixtures/test-pre-gzip.js.br`, zlib.brotliCompressSync(JSON.stringify({
fs.outputFile('fixtures/test-pre-gzip.js.br', zlib.brotliCompressSync(JSON.stringify({
'Content-Type': 'text/javascript; charset=utf-8',
'Content-Encoding': 'br'
})), errorCb)
Expand Down

0 comments on commit c8d1661

Please sign in to comment.