1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 07:00:55 +00:00

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

windows下路径需要filepath.ToSlash

This reverts commit 2c8cb5693e.
This commit is contained in:
nkbai 2015-12-04 23:15:06 +08:00
parent ff0762cc19
commit 82e0105d22

View File

@ -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
}