mirror of
https://github.com/caddyserver/caddy.git
synced 2025-12-08 06:09:53 +00:00
encode: modernize, replace HasSuffix+TrimSuffix with CutSuffix (#7357)
Signed-off-by: ledigang <shuangcui@msn.com>
This commit is contained in:
parent
b9e6f3b227
commit
2cb426776c
1 changed files with 2 additions and 2 deletions
|
|
@ -168,8 +168,8 @@ func (enc *Encode) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyh
|
||||||
// caches without knowing about our changes...
|
// caches without knowing about our changes...
|
||||||
if etag := r.Header.Get("If-None-Match"); etag != "" && !strings.HasPrefix(etag, "W/") {
|
if etag := r.Header.Get("If-None-Match"); etag != "" && !strings.HasPrefix(etag, "W/") {
|
||||||
ourSuffix := "-" + encName + `"`
|
ourSuffix := "-" + encName + `"`
|
||||||
if strings.HasSuffix(etag, ourSuffix) {
|
if before, ok := strings.CutSuffix(etag, ourSuffix); ok {
|
||||||
etag = strings.TrimSuffix(etag, ourSuffix) + `"`
|
etag = before + `"`
|
||||||
r.Header.Set("If-None-Match", etag)
|
r.Header.Set("If-None-Match", etag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue