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

beego: filter the static file's url

This commit is contained in:
astaxie 2014-04-07 14:20:30 +08:00
parent 3fe4f8c362
commit 4124760706
2 changed files with 3 additions and 2 deletions

View File

@ -138,6 +138,7 @@ func SetStaticPath(url string, path string) *App {
if !strings.HasPrefix(url, "/") { if !strings.HasPrefix(url, "/") {
url = "/" + url url = "/" + url
} }
url = strings.TrimRight(url, "/")
StaticDir[url] = path StaticDir[url] = path
return BeeApp return BeeApp
} }

View File

@ -306,9 +306,9 @@ func ParseConfig() (err error) {
sds := strings.Fields(sd) sds := strings.Fields(sd)
for _, v := range sds { for _, v := range sds {
if url2fsmap := strings.SplitN(v, ":", 2); len(url2fsmap) == 2 { if url2fsmap := strings.SplitN(v, ":", 2); len(url2fsmap) == 2 {
StaticDir["/"+url2fsmap[0]] = url2fsmap[1] StaticDir["/"+strings.TrimRight(url2fsmap[0], "/")] = url2fsmap[1]
} else { } else {
StaticDir["/"+url2fsmap[0]] = url2fsmap[0] StaticDir["/"+strings.TrimRight(url2fsmap[0], "/")] = url2fsmap[0]
} }
} }
} }