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 }