Skip to content

Commit

Permalink
refactor(index): replace typeof undefined check
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs authored Oct 29, 2023
1 parent e4661f3 commit 4bffc09
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
Expand All @@ -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) {
Expand Down

0 comments on commit 4bffc09

Please sign in to comment.