From 8f07435b71e5f7707a97f9c5a3f9b264696efb87 Mon Sep 17 00:00:00 2001 From: Evan Hahn Date: Sat, 27 Apr 2024 16:43:59 +0000 Subject: [PATCH] Content-Security-Policy can now use Object.hasOwn We can use this now that we require Node 18+. --- middlewares/content-security-policy/index.ts | 5 +---- tsconfig.json | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/middlewares/content-security-policy/index.ts b/middlewares/content-security-policy/index.ts index e8b65ce..5fb9eb0 100644 --- a/middlewares/content-security-policy/index.ts +++ b/middlewares/content-security-policy/index.ts @@ -93,9 +93,6 @@ const warnIfDirectiveValueEntryShouldBeQuoted = (value: string): void => { } }; -const has = (obj: Readonly, key: string): boolean => - Object.prototype.hasOwnProperty.call(obj, key); - function normalizeDirectives( options: Readonly, ): NormalizedDirectives { @@ -109,7 +106,7 @@ function normalizeDirectives( const directivesExplicitlyDisabled = new Set(); for (const rawDirectiveName in rawDirectives) { - if (!has(rawDirectives, rawDirectiveName)) { + if (!Object.hasOwn(rawDirectives, rawDirectiveName)) { continue; } diff --git a/tsconfig.json b/tsconfig.json index 7ef3ad8..952dae9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,7 @@ "noUnusedParameters": true, "noUncheckedIndexedAccess": true, "strict": true, - "target": "es6", + "target": "es2022", "outDir": "." }, "exclude": ["node_modules"]