diff --git a/doc/api/zlib.md b/doc/api/zlib.md index f57b3d0599bbbe..0995a51e7fd908 100644 --- a/doc/api/zlib.md +++ b/doc/api/zlib.md @@ -102,10 +102,10 @@ http.createServer((request, response) => { // Note: This is not a conformant accept-encoding parser. // See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3 - if (acceptEncoding.match(/\bdeflate\b/)) { + if (/\bdeflate\b/.test(acceptEncoding)) { response.writeHead(200, { 'Content-Encoding': 'deflate' }); raw.pipe(zlib.createDeflate()).pipe(response); - } else if (acceptEncoding.match(/\bgzip\b/)) { + } else if (/\bgzip\b/.test(acceptEncoding)) { response.writeHead(200, { 'Content-Encoding': 'gzip' }); raw.pipe(zlib.createGzip()).pipe(response); } else { @@ -119,7 +119,7 @@ By default, the `zlib` methods will throw an error when decompressing truncated data. However, if it is known that the data is incomplete, or the desire is to inspect only the beginning of a compressed file, it is possible to suppress the default error handling by changing the flushing -method that is used to compressed the last chunk of input data: +method that is used to decompress the last chunk of input data: ```js // This is a truncated version of the buffer from the above examples @@ -127,7 +127,7 @@ const buffer = Buffer.from('eJzT0yMA', 'base64'); zlib.unzip( buffer, - {finishFlush: zlib.constants.Z_SYNC_FLUSH}, + { finishFlush: zlib.constants.Z_SYNC_FLUSH }, (err, buffer) => { if (!err) { console.log(buffer.toString());