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

fix the static url with / problem

This commit is contained in:
astaxie 2016-02-02 12:43:45 +08:00
parent 631b4d36f9
commit 4906b600e3

View File

@ -272,7 +272,9 @@ func SetStaticPath(url string, path string) *App {
if !strings.HasPrefix(url, "/") { if !strings.HasPrefix(url, "/") {
url = "/" + url url = "/" + url
} }
url = strings.TrimRight(url, "/") if url != "/" {
url = strings.TrimRight(url, "/")
}
BConfig.WebConfig.StaticDir[url] = path BConfig.WebConfig.StaticDir[url] = path
return BeeApp return BeeApp
} }
@ -282,7 +284,9 @@ func DelStaticPath(url string) *App {
if !strings.HasPrefix(url, "/") { if !strings.HasPrefix(url, "/") {
url = "/" + url url = "/" + url
} }
url = strings.TrimRight(url, "/") if url != "/" {
url = strings.TrimRight(url, "/")
}
delete(BConfig.WebConfig.StaticDir, url) delete(BConfig.WebConfig.StaticDir, url)
return BeeApp return BeeApp
} }