Skip to content

Commit 433e348

Browse files
sohrbEvanHahn
authored andcommitted
HSTS: throw when misspelling "includeSubDomains" option
See [#462] and [#464]. [#462]: #462 [#464]: #464
1 parent aeba96b commit 433e348

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

middlewares/strict-transport-security/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function getHeaderValueFromOptions(
2929
);
3030
}
3131
if ("includeSubdomains" in options) {
32-
console.warn(
32+
throw new Error(
3333
'Strict-Transport-Security middleware should use `includeSubDomains` instead of `includeSubdomains`. (The correct one has an uppercase "D".)',
3434
);
3535
}

test/strict-transport-security.test.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,9 @@ describe("Strict-Transport-Security middleware", () => {
8787
});
8888

8989
it("logs a warning when using the mis-capitalized `includeSubdomains` parameter", () => {
90-
jest.spyOn(console, "warn").mockImplementation(() => {});
91-
92-
strictTransportSecurity({ includeSubdomains: false } as any);
93-
94-
expect(console.warn).toHaveBeenCalledTimes(1);
95-
expect(console.warn).toHaveBeenCalledWith(
90+
expect(() =>
91+
strictTransportSecurity({ includeSubdomains: false } as any),
92+
).toThrow(
9693
'Strict-Transport-Security middleware should use `includeSubDomains` instead of `includeSubdomains`. (The correct one has an uppercase "D".)',
9794
);
9895
});

0 commit comments

Comments
 (0)