Unverified Commit fc75baeb authored by matamatanot's avatar matamatanot Committed by GitHub

Move sizes var declaration just before used (#18402)

As with `const width`, it should be declared just before it is used.
parent 104b8d47
...@@ -34,7 +34,6 @@ export async function imageOptimizer( ...@@ -34,7 +34,6 @@ export async function imageOptimizer(
const { nextConfig, distDir } = server const { nextConfig, distDir } = server
const imageData: ImageConfig = nextConfig.images || imageConfigDefault const imageData: ImageConfig = nextConfig.images || imageConfigDefault
const { deviceSizes = [], imageSizes = [], domains = [], loader } = imageData const { deviceSizes = [], imageSizes = [], domains = [], loader } = imageData
const sizes = [...deviceSizes, ...imageSizes]
if (loader !== 'default') { if (loader !== 'default') {
await server.render404(req, res, parsedUrl) await server.render404(req, res, parsedUrl)
...@@ -115,6 +114,8 @@ export async function imageOptimizer( ...@@ -115,6 +114,8 @@ export async function imageOptimizer(
return { finished: true } return { finished: true }
} }
const sizes = [...deviceSizes, ...imageSizes]
if (!sizes.includes(width)) { if (!sizes.includes(width)) {
res.statusCode = 400 res.statusCode = 400
res.end(`"w" parameter (width) of ${width} is not allowed`) res.end(`"w" parameter (width) of ${width} is not allowed`)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment