lambda-api
Advanced tools
Comparing version 0.11.0 to 0.11.1
@@ -48,3 +48,5 @@ 'use strict'; | ||
this._compression = | ||
props && typeof props.compression === 'boolean' | ||
props && | ||
(typeof props.compression === 'boolean' || | ||
Array.isArray(props.compression)) | ||
? props.compression | ||
@@ -51,0 +53,0 @@ : false; |
@@ -11,3 +11,6 @@ 'use strict'; | ||
exports.compress = (input, headers) => { | ||
const defaultEnabledEcodings = ['gzip', 'deflate']; | ||
exports.compress = (input, headers, _enabledEncodings) => { | ||
const enabledEncodings = new Set(_enabledEncodings || defaultEnabledEcodings); | ||
const acceptEncodingHeader = headers['accept-encoding'] || ''; | ||
@@ -24,2 +27,3 @@ const acceptableEncodings = new Set( | ||
acceptableEncodings.has('br') && | ||
enabledEncodings.has('br') && | ||
typeof zlib.brotliCompressSync === 'function' | ||
@@ -34,3 +38,3 @@ ) { | ||
// Handle Gzip compression | ||
if (acceptableEncodings.has('gzip')) { | ||
if (acceptableEncodings.has('gzip') && enabledEncodings.has('gzip')) { | ||
return { | ||
@@ -43,3 +47,3 @@ data: zlib.gzipSync(input), | ||
// Handle deflate compression | ||
if (acceptableEncodings.has('deflate')) { | ||
if (acceptableEncodings.has('deflate') && enabledEncodings.has('deflate')) { | ||
return { | ||
@@ -46,0 +50,0 @@ data: zlib.deflateSync(input), |
@@ -569,3 +569,4 @@ 'use strict'; | ||
this._response.body, | ||
this._request.headers | ||
this._request.headers, | ||
Array.isArray(this._compression) ? this._compression : null | ||
); | ||
@@ -572,0 +573,0 @@ if (contentEncoding) { |
{ | ||
"name": "lambda-api", | ||
"version": "0.11.0", | ||
"version": "0.11.1", | ||
"description": "Lightweight web framework for your serverless applications", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
161415
2380
1509
0