added redirect anchors
This commit is contained in:
parent
5e5b73884b
commit
b13ff70a2d
4 changed files with 44 additions and 18 deletions
|
|
@ -37,9 +37,10 @@ func (fs *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
fs.log.Info("access",
|
||||
"uri", r.RequestURI,
|
||||
"client", r.RemoteAddr,
|
||||
"method", r.Method,
|
||||
"status", s.Status(),
|
||||
"uri", r.RequestURI,
|
||||
)
|
||||
}()
|
||||
upath := r.URL.Path
|
||||
|
|
@ -65,13 +66,11 @@ func (fs *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
if !d.IsDir() {
|
||||
if r.FormValue("p") == "t" {
|
||||
fs.fs.Preload(p)
|
||||
idx := strings.LastIndex(p, "/")
|
||||
if idx > 0 {
|
||||
p = p[:idx]
|
||||
} else {
|
||||
p = "/"
|
||||
rdir := "/"
|
||||
if i := strings.LastIndex(p, "/"); i > 0 {
|
||||
rdir = p[:i]
|
||||
}
|
||||
http.Redirect(w, r, p, http.StatusFound)
|
||||
http.Redirect(w, r, rdir+"#"+anchor(p), http.StatusFound)
|
||||
return
|
||||
}
|
||||
if r.FormValue("n") == "t" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue