diff --git a/index.js b/index.js index c0638e08..5739707f 100644 --- a/index.js +++ b/index.js @@ -40,7 +40,7 @@ var hasBrotliSupport = 'createBrotliCompress' in zlib * Module variables. * @private */ -var cacheControlNoTransformRegExp = /(?:^|,)\s*?no-transform\s*?(?:,|$)/ +var cacheControlNoTransformRegExp = /(?:^|,)\s*?no-transform\s*?(?:,|$)/i var SUPPORTED_ENCODING = hasBrotliSupport ? ['br', 'gzip', 'deflate', 'identity'] : ['gzip', 'deflate', 'identity'] var PREFERRED_ENCODING = hasBrotliSupport ? ['br', 'gzip'] : ['gzip'] diff --git a/test/compression.js b/test/compression.js index 8107def0..df37eca2 100644 --- a/test/compression.js +++ b/test/compression.js @@ -706,6 +706,21 @@ describe('compression()', function () { .expect(200, 'hello, world', done) }) + it('should match directive case-insensitively', function (done) { + var server = createServer({ threshold: 0 }, function (req, res) { + res.setHeader('Cache-Control', 'No-Transform') + res.setHeader('Content-Type', 'text/plain') + res.end('hello, world') + }) + + request(server) + .get('/') + .set('Accept-Encoding', 'gzip') + .expect('Cache-Control', 'No-Transform') + .expect(shouldNotHaveHeader('Content-Encoding')) + .expect(200, 'hello, world', done) + }) + it('should not set Vary headerh', function (done) { var server = createServer({ threshold: 0 }, function (req, res) { res.setHeader('Cache-Control', 'no-transform')