From cf4cd8602cf836617933a56bc3a1c103ecdb9e21 Mon Sep 17 00:00:00 2001 From: Francesco Carnielli Date: Tue, 27 Jan 2015 10:13:09 +0100 Subject: [PATCH] check for the right algorithm remove ternary operator and use if...else --- index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index b3ebda0f..201b2ce0 100644 --- a/index.js +++ b/index.js @@ -166,10 +166,15 @@ function compression(options) { } // compression stream + if (method === 'gzip') { + stream = zlib.createGzip(opts) + } else if (method === 'deflate') { + stream = zlib.createDeflate(opts) + } else { + nocompress('not acceptable') + return + } debug('%s compression', method) - stream = method === 'gzip' - ? zlib.createGzip(opts) - : zlib.createDeflate(opts) // add bufferred listeners to stream addListeners(stream, stream.on, listeners)