From 155f3dc0ac970650e40ad65b35530ecfac53c865 Mon Sep 17 00:00:00 2001 From: "lauren n. liberda" Date: Sun, 24 Mar 2024 15:48:11 +0100 Subject: [PATCH 1/2] core(fix): recognize zstd as a compression algorithm bug: https://github.com/GoogleChrome/lighthouse/issues/15882 --- core/lib/network-request.js | 2 +- core/test/lib/network-request-test.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/core/lib/network-request.js b/core/lib/network-request.js index da45a527aa85..dd434495c3be 100644 --- a/core/lib/network-request.js +++ b/core/lib/network-request.js @@ -634,7 +634,7 @@ class NetworkRequest { /^content-encoding$/i, /^x-content-encoding-over-network$/i, ]; - const compressionTypes = ['gzip', 'br', 'deflate']; + const compressionTypes = ['gzip', 'br', 'deflate', 'zstd']; return record.responseHeaders.some(header => patterns.some(p => header.name.match(p)) && compressionTypes.includes(header.value) ); diff --git a/core/test/lib/network-request-test.js b/core/test/lib/network-request-test.js index cc25dd691889..fbbed066e144 100644 --- a/core/test/lib/network-request-test.js +++ b/core/test/lib/network-request-test.js @@ -389,4 +389,22 @@ describe('NetworkRequest', () => { })).toBe(false); }); }); + + describe('#isContentEncoded', () => { + const isContentEncoded = NetworkRequest.isContentEncoded; + + it('correctly identifies no compression', () => { + expect(isContentEncoded({responseHeaders: {}})).toBe(false); + }); + it('correctly identifies brotli', () => { + expect(isContentEncoded({ + responseHeaders: [{name: 'content-encoding', value: 'br'}], + })).toBe(true); + }); + it('correctly identifies zstd', () => { + expect(isContentEncoded({ + responseHeaders: [{name: 'content-encoding', value: 'zstd'}], + })).toBe(true); + }); + }); }); From e65a4e3bb4ee5e4fd23d0f0a6ad8ac6fc11afc0e Mon Sep 17 00:00:00 2001 From: "lauren n. liberda" Date: Mon, 25 Mar 2024 14:47:37 +0100 Subject: [PATCH 2/2] fixup! core(fix): recognize zstd as a compression algorithm bug: https://github.com/GoogleChrome/lighthouse/issues/15882 --- core/test/lib/network-request-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/test/lib/network-request-test.js b/core/test/lib/network-request-test.js index fbbed066e144..2a48e292621f 100644 --- a/core/test/lib/network-request-test.js +++ b/core/test/lib/network-request-test.js @@ -394,7 +394,7 @@ describe('NetworkRequest', () => { const isContentEncoded = NetworkRequest.isContentEncoded; it('correctly identifies no compression', () => { - expect(isContentEncoded({responseHeaders: {}})).toBe(false); + expect(isContentEncoded({responseHeaders: []})).toBe(false); }); it('correctly identifies brotli', () => { expect(isContentEncoded({