Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(index): replace typeof undefined check #274

Merged
merged 1 commit into from
Oct 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ function fastifyCompress (fastify, opts, next) {
// add onSend hook onto each route as needed
fastify.addHook('onRoute', (routeOptions) => {
// If route config.compress has been set it takes precedence over compress
if (routeOptions.config && typeof routeOptions.config.compress !== 'undefined') {
if (routeOptions.config?.compress !== undefined) {
routeOptions.compress = routeOptions.config.compress
}

// Manage compression options
if (typeof routeOptions.compress !== 'undefined') {
if (routeOptions.compress !== undefined) {
Fdawgs marked this conversation as resolved.
Show resolved Hide resolved
if (typeof routeOptions.compress === 'object') {
const mergedCompressParams = Object.assign(
{}, globalCompressParams, processCompressParams(routeOptions.compress)
Expand All @@ -80,12 +80,12 @@ function fastifyCompress (fastify, opts, next) {
}

// If route config.decompress has been set it takes precedence over compress
if (routeOptions.config && typeof routeOptions.config.decompress !== 'undefined') {
if (routeOptions.config?.decompress !== undefined) {
routeOptions.decompress = routeOptions.config.decompress
}

// Manage decompression options
if (typeof routeOptions.decompress !== 'undefined') {
if (routeOptions.decompress !== undefined) {
if (typeof routeOptions.decompress === 'object') {
// if the current endpoint has a custom compress configuration ...
const mergedDecompressParams = Object.assign(
Expand Down
Loading