From 82e0105d22b9defd73c1d8815f9ff9f3952b2692 Mon Sep 17 00:00:00 2001 From: nkbai Date: Fri, 4 Dec 2015 23:15:06 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"windows=E4=B8=8B=E9=9D=99=E6=80=81?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=98=A0=E5=B0=84=E6=89=BE=E4=B8=8D=E5=88=B0?= =?UTF-8?q?=E9=97=AE=E9=A2=98,"=20windows=E4=B8=8B=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E9=9C=80=E8=A6=81filepath.ToSlash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 2c8cb5693ee650b4352926cf178d5d24786698ff. --- staticfile.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/staticfile.go b/staticfile.go index 90d0be0d..f2eb0654 100644 --- a/staticfile.go +++ b/staticfile.go @@ -19,6 +19,7 @@ import ( "net/http" "os" "path" + "path/filepath" "strconv" "strings" "sync" @@ -143,7 +144,7 @@ func isStaticCompress(filePath string) bool { // searchFile search the file by url path // if none the static file prefix matches ,return notStaticRequestErr func searchFile(ctx *context.Context) (string, os.FileInfo, error) { - requestPath := path.Clean(ctx.Input.Request.URL.Path) + requestPath := filepath.ToSlash(filepath.Clean(ctx.Input.Request.URL.Path)) // special processing : favicon.ico/robots.txt can be in any static dir if requestPath == "/favicon.ico" || requestPath == "/robots.txt" { file := path.Join(".", requestPath) @@ -188,7 +189,7 @@ func lookupFile(ctx *context.Context) (bool, string, os.FileInfo, error) { if !fi.IsDir() { return false, fp, fi, err } - ifp := path.Join(fp, "index.html") + ifp := filepath.Join(fp, "index.html") if ifi, _ := os.Stat(ifp); ifi != nil && ifi.Mode().IsRegular() { return false, ifp, ifi, err }