From 0381b6e4ae73f77118ad9faf5e924d4d4911fb1e Mon Sep 17 00:00:00 2001 From: rramiachraf <51409801+rramiachraf@users.noreply.github.com> Date: Thu, 30 May 2024 18:40:19 +0100 Subject: [PATCH] fix: images proxy handler now handle all image types --- handlers/proxy.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/handlers/proxy.go b/handlers/proxy.go index cec3b11..b85ff82 100644 --- a/handlers/proxy.go +++ b/handlers/proxy.go @@ -14,11 +14,14 @@ import ( ) func isValidExt(ext string) bool { - valid := []string{"jpg", "jpeg", "png", "gif"} - for _, c := range valid { - if strings.ToLower(ext) == c { - return true - } + extType := mime.TypeByExtension("." + strings.ToLower(ext)) + isImage, _, found := strings.Cut(extType, "/") + if !found { + return false + } + + if isImage == "image" { + return true } return false