Skip to content

Commit f48e823

Browse files
committed
don't directly manipulate the object.
1 parent 9c66eb9 commit f48e823

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var Negotiator = require('negotiator')
1818
var Buffer = require('safe-buffer').Buffer
1919
var bytes = require('bytes')
2020
var compressible = require('compressible')
21+
var objectAssign = require('object-assign')
2122
var debug = require('debug')('compression')
2223
var onHeaders = require('on-headers')
2324
var vary = require('vary')
@@ -54,14 +55,14 @@ var PREFERRED_ENCODING = hasBrotliSupport ? ['br', 'gzip'] : ['gzip']
5455

5556
function compression (options) {
5657
var opts = options || {}
57-
var optsBrotli = opts.brotli || {}
58+
var optsBrotli = objectAssign({}, opts.brotli)
5859

5960
if (hasBrotliSupport) {
60-
// set the default level to a reasonable value with balanced speed/ratio
6161
if (optsBrotli.params === undefined) {
6262
optsBrotli.params = {}
6363
}
6464

65+
// set the default level to a reasonable value with balanced speed/ratio
6566
if (optsBrotli.params[zlib.constants.BROTLI_PARAM_QUALITY] === undefined) {
6667
optsBrotli.params[zlib.constants.BROTLI_PARAM_QUALITY] = 4
6768
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"compressible": "~2.0.18",
1414
"debug": "2.6.9",
1515
"negotiator": "~0.6.4",
16+
"object-assign": "~4.1.1",
1617
"on-headers": "~1.0.2",
1718
"safe-buffer": "5.2.1",
1819
"vary": "~1.1.2"

0 commit comments

Comments
 (0)