Skip to content

Commit

Permalink
Content-Security-Policy can now use Object.hasOwn
Browse files Browse the repository at this point in the history
We can use this now that we require Node 18+.
  • Loading branch information
EvanHahn committed Sep 28, 2024
1 parent 293bd18 commit 76410e1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions middlewares/content-security-policy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ const warnIfDirectiveValueEntryShouldBeQuoted = (value: string): void => {
}
};

const has = (obj: Readonly<object>, key: string): boolean =>
Object.prototype.hasOwnProperty.call(obj, key);

function normalizeDirectives(
options: Readonly<ContentSecurityPolicyOptions>,
): NormalizedDirectives {
Expand All @@ -109,7 +106,7 @@ function normalizeDirectives(
const directivesExplicitlyDisabled = new Set<string>();

for (const rawDirectiveName in rawDirectives) {
if (!has(rawDirectives, rawDirectiveName)) {
if (!Object.hasOwn(rawDirectives, rawDirectiveName)) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"noUncheckedIndexedAccess": true,
"noUncheckedSideEffectImports": true,
"strict": true,
"target": "es6",
"target": "es2022",
"outDir": "."
},
"exclude": ["node_modules"]
Expand Down

0 comments on commit 76410e1

Please sign in to comment.