From ffa1aff4618fa82f8d63540f58a6b8715d7ec62c Mon Sep 17 00:00:00 2001 From: ache Date: Sun, 17 Feb 2019 20:57:18 +0100 Subject: Fix Path --- server.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/server.go b/server.go index 3228bef..de88dcf 100644 --- a/server.go +++ b/server.go @@ -43,6 +43,7 @@ func handleGet( w http.ResponseWriter, r *http.Request, headOnly bool) { type Entry struct { Name string + Path string Size int64 } @@ -72,16 +73,18 @@ func handleGet( w http.ResponseWriter, r *http.Request, headOnly bool) { } } + initPath := r.URL.Path; - cols = append(cols, Entry{".", 0}) - if filename != "." { - cols = append(cols, Entry{"..", 0}) + cols = append(cols, Entry{".", initPath, 0}) + if initPath != "/" { + cols = append(cols, Entry{"..", path.Dir(initPath), 0}) + initPath += "/" } for _, file := range fileInfo { if file.IsDir() { - cols = append(cols, Entry{file.Name(), 0}) + cols = append(cols, Entry{file.Name(), initPath + file.Name(), 0}) } else { - files = append(files, Entry{file.Name(), file.Size()}) + files = append(files, Entry{file.Name(), initPath + file.Name(), file.Size()}) } } type Collection struct { -- cgit v1.2.3