From 988a10974b88c6859388aacf100a0001eaf69455 Mon Sep 17 00:00:00 2001 From: vorotamoroz Date: Wed, 4 Nov 2026 03:02:32 +0000 Subject: [PATCH] Test empty cache directive lists --- .../services/nativeRequestHeaders.unit.spec.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/modules/services/nativeRequestHeaders.unit.spec.ts b/src/modules/services/nativeRequestHeaders.unit.spec.ts index 96455ef5..0f74b21f 100644 --- a/src/modules/services/nativeRequestHeaders.unit.spec.ts +++ b/src/modules/services/nativeRequestHeaders.unit.spec.ts @@ -77,6 +77,20 @@ describe("native request header creation", () => { }); }); + it.each([ + ["", "no-cache"], + [", , ,", "no-cache"], + [" , no-transform , , ", "no-transform, no-cache"], + ])("ignores empty header-list members in %j", (value, expected) => { + const headers = Object.freeze({ "Cache-Control": value, Pragma: " , , " }); + + expect(createNativeRequestHeaders(headers, "GET", "no-cache")).toEqual({ + "Cache-Control": expected, + Pragma: "no-cache", + }); + expect(headers["Cache-Control"]).toBe(value); + }); + it("retains cache headers on a non-revalidated method", () => { const headers = { "cache-control": "max-age=99", Pragma: "legacy" }; expect(createNativeRequestHeaders(headers, "POST", "no-store")).toEqual(headers);