From d1a55830d1946ca75ac571399d174a5d8eedc06e Mon Sep 17 00:00:00 2001 From: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Date: Fri, 22 May 2026 02:17:44 -0700 Subject: [PATCH] fix(imageopto): correct contrast URL parameter spelling The Contrast option in imageopto.go:884 was building URLs with `constrast=`, but Fastly's Image Optimizer expects the parameter to be spelled `contrast` (per https://www.fastly.com/documentation/reference/io/contrast/). The typo meant any user setting `Options{Contrast: ...}` was silently sending an unknown query parameter that Image Optimizer ignored, so the SDK option has effectively been a no-op since it was introduced. Rename the URL parameter to the correct `contrast` spelling in both the builder (imageopto.go) and the testdata fixture (imageopto_test.go). The existing test now asserts the correct URL, so `go test ./fsthttp/imageopto/...` exercises the corrected behavior. Fixes #258 Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> --- fsthttp/imageopto/imageopto.go | 2 +- fsthttp/imageopto/imageopto_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsthttp/imageopto/imageopto.go b/fsthttp/imageopto/imageopto.go index bc825d7..b2ad73c 100644 --- a/fsthttp/imageopto/imageopto.go +++ b/fsthttp/imageopto/imageopto.go @@ -881,7 +881,7 @@ func (o *Options) QueryString() (string, error) { } if o.Contrast != 0 { - args = append(args, "constrast="+strconv.Itoa(o.Contrast)) + args = append(args, "contrast="+strconv.Itoa(o.Contrast)) } if o.Crop != nil { diff --git a/fsthttp/imageopto/imageopto_test.go b/fsthttp/imageopto/imageopto_test.go index 9ef37d2..fbb4f08 100644 --- a/fsthttp/imageopto/imageopto_test.go +++ b/fsthttp/imageopto/imageopto_test.go @@ -16,7 +16,7 @@ func TestOpts(t *testing.T) { {&Options{Region: RegionUsEast, Blur: NewBlurModePercentage(0.8)}, "region=us_east&blur=0.8p"}, {&Options{Region: RegionUsEast, Brightness: -50}, "region=us_east&brightness=-50"}, {&Options{Region: RegionUsEast, Bw: NewBWModeThreshold(10)}, "region=us_east&bw=threshold,10"}, - {&Options{Region: RegionUsEast, Contrast: -5}, "region=us_east&constrast=-5"}, + {&Options{Region: RegionUsEast, Contrast: -5}, "region=us_east&contrast=-5"}, {&Options{Region: RegionUsEast, Dpr: 3.2}, "region=us_east&dpr=3.2"}, {&Options{Region: RegionUsEast, Enable: EnableOptUpscale}, "region=us_east&enable=upscale"}, {&Options{Region: RegionUsEast, Format: FormatJPEGXL}, "region=us_east&format=jpegxl"},