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,15 +288,13 @@ export class ImageOptimizerCache {
}
}
if (qualities) {
if (isDev) {
qualities.push(BLUR_QUALITY)
}
if (!qualities.includes(quality)) {
return {
errorMessage: `"q" parameter (quality) of ${q} is not allowed`,
}
if (
qualities &&
!qualities.includes(quality) &&
!(isDev && quality === BLUR_QUALITY)
) {
return {
errorMessage: `"q" parameter (quality) of ${q} 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