Commit 82e0105d authored by nkbai's avatar nkbai

Revert "windows下静态文件映射找不到问题,"

windows下路径需要filepath.ToSlash

This reverts commit 2c8cb569.
parent ff0762cc
......@@ -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
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment