Browse Source

Fix up to parent directory

master
Lunny Xiao 2 months ago
parent
commit
b786e0bcf4
Signed by: lunny <xiaolunwen@gmail.com> GPG Key ID: C3B7C91B632F738A
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      static.go

+ 5
- 1
static.go View File

@@ -155,7 +155,11 @@ func Static(opts ...StaticOptions) HandlerFunc {
ctx.Header().Set("Content-Type", "text/html; charset=UTF-8")
ctx.WriteString(`<ul style="list-style-type:none;line-height:32px;">`)
if rPath != "/" {
ctx.WriteString(`<li>&nbsp; &nbsp; <a href="` + path.Join("/", opt.Prefix, path.Dir(strings.TrimSuffix(rPath, "/"))) + `/">..</a></li>`)
parentPath := path.Join("/", opt.Prefix, path.Dir(strings.TrimSuffix(rPath, "/")))
if !strings.HasSuffix(parentPath, "/") {
parentPath += "/"
}
ctx.WriteString(`<li>&nbsp; &nbsp; <a href="` + parentPath + `">..</a></li>`)
}

fs, err := f.Readdir(0)


Loading…
Cancel
Save