@marcel91200 / caddy Mirror · read-only / commits / 2cb42677
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 11, 18:30 UTC

encode: modernize, replace HasSuffix+TrimSuffix with CutSuffix (#7357)

Signed-off-by: ledigang <shuangcui@msn.com>

ledigang committed Nov 22, 2025 at 06:30 UTC 2cb426776c091febccc6b9a6669f1c5a745648a4
1 file changed +2 -2
modules/caddyhttp/encode/encode.go
+2 -2
@@ -168,8 +168,8 @@ func (enc *Encode) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyh
168 // caches without knowing about our changes...
169 if etag := r.Header.Get("If-None-Match"); etag != "" && !strings.HasPrefix(etag, "W/") {
170 ourSuffix := "-" + encName + `"`
171 - if strings.HasSuffix(etag, ourSuffix) {
172 - etag = strings.TrimSuffix(etag, ourSuffix) + `"`
171 + if before, ok := strings.CutSuffix(etag, ourSuffix); ok {
172 + etag = before + `"`
173 r.Header.Set("If-None-Match", etag)
174 }
175 }