summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/fileserver
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2020-12-30 08:03:33 -0700
committerMatthew Holt <mholt@users.noreply.github.com>2020-12-30 08:05:01 -0700
commitd8bcf5be4e0f548c7beeaca36c8a134e32418dc8 (patch)
tree7128e3c3cd25762d92ff06d681c8fb3b20e4bf01 /modules/caddyhttp/fileserver
parent38a83ca6f8f52d08bf47775518b51bf135978294 (diff)
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.
Diffstat (limited to 'modules/caddyhttp/fileserver')
-rw-r--r--modules/caddyhttp/fileserver/browse.go5
1 files changed, 2 insertions, 3 deletions
diff --git a/modules/caddyhttp/fileserver/browse.go b/modules/caddyhttp/fileserver/browse.go
index 1f6986f..2712077 100644
--- a/modules/caddyhttp/fileserver/browse.go
+++ b/modules/caddyhttp/fileserver/browse.go
@@ -99,9 +99,8 @@ func (fsrv *FileServer) loadDirectoryContents(dir *os.File, root, urlPath string
return browseListing{}, err
}
- // determine if user can browse up another folder
- curPathDir := path.Dir(strings.TrimSuffix(urlPath, "/"))
- canGoUp := strings.HasPrefix(curPathDir, root)
+ // user can presumably browse "up" to parent folder if path is longer than "/"
+ canGoUp := len(urlPath) > 1
return fsrv.directoryListing(files, canGoUp, root, urlPath, repl), nil
}