diff --git a/CHANGELOG.md b/CHANGELOG.md index e043ce8..71c03bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,16 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Changed - updated docker image to use go1.12 compiler and build imageproxy as a go module. + - options are now sorted when converting to string. This is a breaking change + for anyone relying on the option order, and will additionally invalidate + most cached values, since the option string is part of the cache key. + + Both the original remote image, as well as any transformations on that image + are cached, but only the transformed images will be impacted by this change. + This will result in imageproxy having to re-perform the transformations, but + should not result in re-fetching the remote image, unless it has already + otherwise expired. + ### Removed - removed deprecated `whitelist` flag and `Proxy.Whitelist` struct field. Use `allowHosts` and `Proxy.AllowHosts` instead. diff --git a/data.go b/data.go index 97b59c5..3968825 100644 --- a/data.go +++ b/data.go @@ -19,6 +19,7 @@ import ( "net/http" "net/url" "regexp" + "sort" "strconv" "strings" ) @@ -133,6 +134,7 @@ func (o Options) String() string { if o.SmartCrop { opts = append(opts, optSmartCrop) } + sort.Strings(opts) return strings.Join(opts, ",") } diff --git a/data_test.go b/data_test.go index 1416613..9e839c7 100644 --- a/data_test.go +++ b/data_test.go @@ -33,19 +33,19 @@ func TestOptions_String(t *testing.T) { }, { Options{1, 2, true, 90, true, true, 80, "", false, "", 0, 0, 0, 0, false}, - "1x2,fit,r90,fv,fh,q80", + "1x2,fh,fit,fv,q80,r90", }, { Options{0.15, 1.3, false, 45, false, false, 95, "c0ffee", false, "png", 0, 0, 0, 0, false}, - "0.15x1.3,r45,q95,sc0ffee,png", + "0.15x1.3,png,q95,r45,sc0ffee", }, { Options{0.15, 1.3, false, 45, false, false, 95, "c0ffee", false, "", 100, 200, 0, 0, false}, - "0.15x1.3,r45,q95,sc0ffee,cx100,cy200", + "0.15x1.3,cx100,cy200,q95,r45,sc0ffee", }, { Options{0.15, 1.3, false, 45, false, false, 95, "c0ffee", false, "png", 100, 200, 300, 400, false}, - "0.15x1.3,r45,q95,sc0ffee,png,cx100,cy200,cw300,ch400", + "0.15x1.3,ch400,cw300,cx100,cy200,png,q95,r45,sc0ffee", }, }