From f7430a2ce19357e72a021751537a09854e0991b1 Mon Sep 17 00:00:00 2001 From: "asta.xie" Date: Wed, 26 Feb 2014 14:44:41 +0800 Subject: [PATCH] enhance the static file path. If user foget / path.Join will auto fix it. --- router.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/router.go b/router.go index bb083768..6a7f8bf6 100644 --- a/router.go +++ b/router.go @@ -8,6 +8,7 @@ import ( "net/http" "net/url" "os" + "path" "reflect" "regexp" "runtime" @@ -546,13 +547,13 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) //static file server for prefix, staticDir := range StaticDir { if r.URL.Path == "/favicon.ico" { - file := staticDir + r.URL.Path + file := path.Join(staticDir, r.URL.Path) http.ServeFile(w, r, file) w.started = true goto Admin } if strings.HasPrefix(r.URL.Path, prefix) { - file := staticDir + r.URL.Path[len(prefix):] + file := path.Join(staticDir, r.URL.Path[len(prefix):]) finfo, err := os.Stat(file) if err != nil { if RunMode == "dev" {