From 4bffc0936038bd88e757e7a05b61d8e15862b367 Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Sun, 29 Oct 2023 05:37:22 +0000 Subject: [PATCH] refactor(index): replace `typeof` undefined check --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index c196e69..45f1b98 100644 --- a/index.js +++ b/index.js @@ -22,7 +22,7 @@ async function fastifyHelmet (fastify, options) { } fastify.addHook('onRoute', (routeOptions) => { - if (typeof routeOptions.helmet !== 'undefined') { + if (routeOptions.helmet !== undefined) { if (typeof routeOptions.helmet === 'object') { routeOptions.config = Object.assign(routeOptions.config || Object.create(null), { helmet: routeOptions.helmet }) } else if (routeOptions.helmet === false) { @@ -38,7 +38,7 @@ async function fastifyHelmet (fastify, options) { const { helmet: routeOptions } = request.routeOptions?.config || request.routeConfig - if (typeof routeOptions !== 'undefined') { + if (routeOptions !== undefined) { const { enableCSPNonces: enableRouteCSPNonces, skipRoute, ...helmetRouteConfiguration } = routeOptions // If route helmet options are set they overwrite the global helmet configuration const mergedHelmetConfiguration = Object.assign(Object.create(null), globalConfiguration, helmetRouteConfiguration) @@ -56,7 +56,7 @@ async function fastifyHelmet (fastify, options) { const { helmet: routeOptions } = request.routeOptions?.config || request.routeConfig - if (typeof routeOptions !== 'undefined') { + if (routeOptions !== undefined) { const { enableCSPNonces: enableRouteCSPNonces, skipRoute, ...helmetRouteConfiguration } = routeOptions if (skipRoute === true) {