Unverified Commit a5cf7ef1 authored by Josh Story's avatar Josh Story Committed by GitHub

Avoid mutating image qualities during validation (#99476)

## Summary

Allow the internal blur quality directly during development image
request validation instead of appending it to `images.qualities`. This
preserves quality validation while removing another runtime config
mutation as part of supporting immutable configuration in Vercel adapter
deployments.

## Verification

Existing HTTP tests in `test/e2e/image-optimizer/sharp.test.ts` cover
blur SVG responses, allowed image requests, and rejection of
unconfigured qualities. The four selected cases pass in Turbopack
development, Webpack development, and Webpack production modes.

<!-- NEXT_JS_LLM -->
parent 423315a7
...@@ -288,17 +288,15 @@ export class ImageOptimizerCache { ...@@ -288,17 +288,15 @@ export class ImageOptimizerCache {
} }
} }
if (qualities) { if (
if (isDev) { qualities &&
qualities.push(BLUR_QUALITY) !qualities.includes(quality) &&
} !(isDev && quality === BLUR_QUALITY)
) {
if (!qualities.includes(quality)) {
return { return {
errorMessage: `"q" parameter (quality) of ${q} is not allowed`, errorMessage: `"q" parameter (quality) of ${q} is not allowed`,
} }
} }
}
const mimeType = getSupportedMimeType(formats || [], req.headers['accept']) const mimeType = getSupportedMimeType(formats || [], req.headers['accept'])
......
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