From 70088f43d4e6358b2ea752398ca1fc843ebb5730 Mon Sep 17 00:00:00 2001 From: Haris Zujo Date: Sat, 26 Sep 2020 09:48:10 +0200 Subject: [PATCH] put max age first in expect-ct middleware --- middlewares/expect-ct/index.ts | 4 ++-- test/expect-ct.test.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/middlewares/expect-ct/index.ts b/middlewares/expect-ct/index.ts index f4a35b8d..85a6a1f2 100644 --- a/middlewares/expect-ct/index.ts +++ b/middlewares/expect-ct/index.ts @@ -27,12 +27,12 @@ function parseMaxAge(value: void | number): number { function getHeaderValueFromOptions(options: Readonly): string { const directives: string[] = []; + directives.push(`max-age=${parseMaxAge(options.maxAge)}`); + if (options.enforce) { directives.push("enforce"); } - directives.push(`max-age=${parseMaxAge(options.maxAge)}`); - if (options.reportUri) { directives.push(`report-uri="${options.reportUri}"`); } diff --git a/test/expect-ct.test.ts b/test/expect-ct.test.ts index c033c11f..e0343761 100644 --- a/test/expect-ct.test.ts +++ b/test/expect-ct.test.ts @@ -43,7 +43,7 @@ describe("Expect-CT middleware", () => { it("can enable enforcement", async () => { await check(expectCt({ enforce: true }), { - "expect-ct": "enforce, max-age=0", + "expect-ct": "max-age=0, enforce", }); }); @@ -68,7 +68,7 @@ describe("Expect-CT middleware", () => { }), { "expect-ct": - 'enforce, max-age=123, report-uri="https://example.com/report"', + 'max-age=123, enforce, report-uri="https://example.com/report"', } ); });