@@ -131,8 +131,8 @@ function processCompressParams (opts) {
131
131
132
132
params . encodings = Array . isArray ( opts . encodings )
133
133
? supportedEncodings
134
- . filter ( encoding => opts . encodings . includes ( encoding ) )
135
- . sort ( ( a , b ) => opts . encodings . indexOf ( a ) - supportedEncodings . indexOf ( b ) )
134
+ . filter ( encoding => opts . encodings . includes ( encoding ) )
135
+ . sort ( ( a , b ) => opts . encodings . indexOf ( a ) - supportedEncodings . indexOf ( b ) )
136
136
: supportedEncodings
137
137
138
138
return params
@@ -163,8 +163,8 @@ function processDecompressParams (opts) {
163
163
164
164
params . encodings = Array . isArray ( opts . requestEncodings )
165
165
? supportedEncodings
166
- . filter ( encoding => opts . requestEncodings . includes ( encoding ) )
167
- . sort ( ( a , b ) => opts . requestEncodings . indexOf ( a ) - supportedEncodings . indexOf ( b ) )
166
+ . filter ( encoding => opts . requestEncodings . includes ( encoding ) )
167
+ . sort ( ( a , b ) => opts . requestEncodings . indexOf ( a ) - supportedEncodings . indexOf ( b ) )
168
168
: supportedEncodings
169
169
170
170
if ( opts . forceRequestEncoding ) {
@@ -213,8 +213,8 @@ function buildRouteCompress (fastify, params, routeOptions, decorateOnly) {
213
213
}
214
214
setVaryHeader ( reply )
215
215
216
- var stream , encoding
217
- var noCompress =
216
+ let stream , encoding
217
+ const noCompress =
218
218
// don't compress on x-no-compression header
219
219
( req . headers [ 'x-no-compression' ] !== undefined ) ||
220
220
// don't compress if not one of the indicated compressible types
@@ -223,9 +223,9 @@ function buildRouteCompress (fastify, params, routeOptions, decorateOnly) {
223
223
( ( encoding = getEncodingHeader ( params . encodings , req ) ) == null || encoding === 'identity' )
224
224
225
225
if ( encoding == null && params . onUnsupportedEncoding != null ) {
226
- var encodingHeader = req . headers [ 'accept-encoding' ]
226
+ const encodingHeader = req . headers [ 'accept-encoding' ]
227
227
try {
228
- var errorPayload = params . onUnsupportedEncoding ( encodingHeader , reply . request , reply )
228
+ const errorPayload = params . onUnsupportedEncoding ( encodingHeader , reply . request , reply )
229
229
return next ( null , errorPayload )
230
230
} catch ( err ) {
231
231
return next ( err )
@@ -328,8 +328,8 @@ function compress (params) {
328
328
}
329
329
330
330
setVaryHeader ( this )
331
- var stream , encoding
332
- var noCompress =
331
+ let stream , encoding
332
+ const noCompress =
333
333
// don't compress on x-no-compression header
334
334
( this . request . headers [ 'x-no-compression' ] !== undefined ) ||
335
335
// don't compress if not one of the indicated compressible types
@@ -338,9 +338,9 @@ function compress (params) {
338
338
( ( encoding = getEncodingHeader ( params . encodings , this . request ) ) == null || encoding === 'identity' )
339
339
340
340
if ( encoding == null && params . onUnsupportedEncoding != null ) {
341
- var encodingHeader = this . request . headers [ 'accept-encoding' ]
341
+ const encodingHeader = this . request . headers [ 'accept-encoding' ]
342
342
343
- var errorPayload
343
+ let errorPayload
344
344
try {
345
345
errorPayload = params . onUnsupportedEncoding ( encodingHeader , this . request , this )
346
346
} catch ( ex ) {
@@ -440,7 +440,7 @@ function getEncodingHeader (encodings, request) {
440
440
441
441
function shouldCompress ( type , compressibleTypes ) {
442
442
if ( compressibleTypes . test ( type ) ) return true
443
- var data = mimedb [ type . split ( ';' , 1 ) [ 0 ] . trim ( ) . toLowerCase ( ) ]
443
+ const data = mimedb [ type . split ( ';' , 1 ) [ 0 ] . trim ( ) . toLowerCase ( ) ]
444
444
if ( data === undefined ) return false
445
445
return data . compressible === true
446
446
}
@@ -455,7 +455,7 @@ function isCompressed (data) {
455
455
function maybeUnzip ( payload , serialize ) {
456
456
if ( isStream ( payload ) ) return payload
457
457
458
- var buf = payload ; var result = payload
458
+ let buf = payload ; let result = payload
459
459
460
460
if ( ArrayBuffer . isView ( payload ) ) {
461
461
// Cast non-Buffer DataViews into a Buffer
0 commit comments