From 7eb3974abbfed7dae94e2aa2b0c08df814a5baaf Mon Sep 17 00:00:00 2001 From: satori Date: Tue, 31 Dec 2024 07:07:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A6=82=E6=9E=9C=E6=9C=AC=E5=9C=B0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=AD=98=E5=9C=A8=EF=BC=8C=E7=9B=B4=E6=8E=A5=E8=BE=93?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/main.go b/bin/main.go index b53ff97..09d544a 100644 --- a/bin/main.go +++ b/bin/main.go @@ -490,6 +490,7 @@ func main() { reg := regexp.MustCompile(`^/img/([0-9a-zA-Z]+)-([0-9a-zA-Z]+).(jpg|jpeg|png|webp)$`) matches := reg.FindStringSubmatch(r.URL.Path) if len(matches) != 4 { + log.Println("URL 格式错误", r.URL.Path) http.Error(w, "URL 格式错误", http.StatusNotFound) return } @@ -524,7 +525,7 @@ func main() { // 如果本地文件存在,直接输出 filePath := filepath.Join("data/webp", r.URL.Path) - if _, err := os.Stat(filePath); err != nil { + if _, err := os.Stat(filePath); err == nil { http.ServeFile(w, r, filePath) return }