Skip to content

Commit 7bd4a67

Browse files
committed
fix(index): add fallback for optional chaining destruct
1 parent 5a99fdc commit 7bd4a67

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ async function fastifyHelmet (fastify, options) {
3434
})
3535

3636
fastify.addHook('onRequest', async function helmetConfigureReply (request, reply) {
37-
const { helmet: routeOptions } = request.routeOptions?.config
37+
const { helmet: routeOptions } = request.routeOptions?.config ?? {}
3838

3939
if (routeOptions !== undefined) {
4040
const { enableCSPNonces: enableRouteCSPNonces, skipRoute, ...helmetRouteConfiguration } = routeOptions
@@ -50,7 +50,7 @@ async function fastifyHelmet (fastify, options) {
5050
})
5151

5252
fastify.addHook('onRequest', function helmetApplyHeaders (request, reply, next) {
53-
const { helmet: routeOptions } = request.routeOptions?.config
53+
const { helmet: routeOptions } = request.routeOptions?.config ?? {}
5454

5555
if (routeOptions !== undefined) {
5656
const { enableCSPNonces: enableRouteCSPNonces, skipRoute, ...helmetRouteConfiguration } = routeOptions

0 commit comments

Comments
 (0)