Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
fileserver: Fix "go up" links in browse listings (closes #3942)
At some point we changed how paths are represented down the function calls of browse listings and forgot to update the canGoUp logic. I think this is right? It's simpler now.
Matthew Holt committed
Dec 30, 2020 at 08:03 UTC
d8bcf5be4e0f548c7beeaca36c8a134e32418dc8
1 file changed
+2
-3
modules/caddyhttp/fileserver/browse.go
+2
-3
@@ -99,9 +99,8 @@ func (fsrv *FileServer) loadDirectoryContents(dir *os.File, root, urlPath string
99
return browseListing{}, err
100
}
101
102
- // determine if user can browse up another folder
103
- curPathDir := path.Dir(strings.TrimSuffix(urlPath, "/"))
104
- canGoUp := strings.HasPrefix(curPathDir, root)
102
+ // user can presumably browse "up" to parent folder if path is longer than "/"
103
+ canGoUp := len(urlPath) > 1
104
105
return fsrv.directoryListing(files, canGoUp, root, urlPath, repl), nil
106
}