From 3e8f109edd5f62c3b14eab3d8191ce164abfc88f Mon Sep 17 00:00:00 2001 From: Antoni Sawicki Date: Mon, 1 Jul 2024 23:15:18 -0700 Subject: [PATCH] use HasSuffix to determine content type --- wrp.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wrp.go b/wrp.go index 3962b90..506efc3 100644 --- a/wrp.go +++ b/wrp.go @@ -537,11 +537,11 @@ func imgServer(w http.ResponseWriter, r *http.Request) { defer delete(img, r.URL.Path) } switch { - case strings.HasPrefix(r.URL.Path, ".gif"): + case strings.HasSuffix(r.URL.Path, ".gif"): w.Header().Set("Content-Type", "image/gif") - case strings.HasPrefix(r.URL.Path, ".png"): + case strings.HasSuffix(r.URL.Path, ".png"): w.Header().Set("Content-Type", "image/png") - case strings.HasPrefix(r.URL.Path, ".jpg"): + case strings.HasSuffix(r.URL.Path, ".jpg"): w.Header().Set("Content-Type", "image/jpeg") } w.Header().Set("Content-Length", strconv.Itoa(len(imgBuf.Bytes())))