Skip to content

Commit cbcf7c0

Browse files
committed
small refactor
1 parent b5e8cce commit cbcf7c0

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

amis.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@ func (a *App) HandleFunc(path string, handler http.HandlerFunc, middlewares ...f
6262

6363
// StaticFS registers a file server for serving static files
6464
func (a *App) StaticFS(prefix string, fs http.FileSystem) {
65-
if prefix == "" || prefix == "/" {
66-
prefix = "/"
67-
}
65+
// regular prefix to: "/xxx/"" (eg. "abc", "/abc", "abc/", "//abc/" all will be changed to "/abc/")
66+
// if prefix is "" or "/", regular it to "/"
6867
prefix = "/" + strings.TrimLeft(prefix, "/")
6968
prefix = strings.TrimRight(prefix, "/") + "/"
7069
a.mux.Handle(prefix, http.StripPrefix(prefix, http.FileServer(fs)))

0 commit comments

Comments
 (0)