From 194be5c972d148a08ec63313a19abf5b5bf9d712 Mon Sep 17 00:00:00 2001 From: Eli Dupuis Date: Fri, 4 Mar 2016 11:20:38 -0700 Subject: [PATCH] Take `filePattern` into account when determining `isGzipped` status Hardcoding `index.html` limits the flexibility here; using `filePattern` sets Content-Encoding header properly when file differs from `index.html`. --- lib/s3.js | 2 +- tests/unit/lib/s3-nodetest.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/s3.js b/lib/s3.js index 159113a..1021f07 100644 --- a/lib/s3.js +++ b/lib/s3.js @@ -44,7 +44,7 @@ module.exports = CoreObject.extend({ var revisionKey = joinUriSegments(options.prefix, key); var putObject = Promise.denodeify(client.putObject.bind(client)); var gzippedFilePaths = options.gzippedFilePaths || []; - var isGzipped = gzippedFilePaths.indexOf('index.html') !== -1; + var isGzipped = gzippedFilePaths.indexOf(options.filePattern) !== -1; var params = { Bucket: bucket, diff --git a/tests/unit/lib/s3-nodetest.js b/tests/unit/lib/s3-nodetest.js index 8a8a316..274ec10 100644 --- a/tests/unit/lib/s3-nodetest.js +++ b/tests/unit/lib/s3-nodetest.js @@ -137,8 +137,8 @@ describe('s3', function() { }); }); - it('sets the Content-Encoding header to gzip when the index file is gziped', function() { - options.gzippedFilePaths = ['index.html']; + it('sets the Content-Encoding header to gzip when the index file is gzipped', function() { + options.gzippedFilePaths = [filePattern]; var promise = subject.upload(options); return assert.isFulfilled(promise)