mirror of
https://github.com/nielsAD/autoindex.git
synced 2026-03-11 10:20:12 +01:00
Fix serving live directories on Windows
This commit is contained in:
5
fs.go
5
fs.go
@@ -383,7 +383,8 @@ interr:
|
||||
}
|
||||
|
||||
func (fs *CachedFS) serveLive(w http.ResponseWriter, r *http.Request) {
|
||||
p := cleanPath(filepath.Join(fs.Root, r.URL.Path))
|
||||
p := filepath.Join(fs.Root, filepath.FromSlash(r.URL.Path), "_")
|
||||
p = p[:len(p)-1]
|
||||
|
||||
resp := make(Files, 0)
|
||||
search, err := regexp.Compile(escapeRegex(r.URL.Query().Get("q")))
|
||||
@@ -406,7 +407,7 @@ func (fs *CachedFS) serveLive(w http.ResponseWriter, r *http.Request) {
|
||||
return nil
|
||||
}
|
||||
|
||||
f := File{Name: r[trim:]}
|
||||
f := File{Name: filepath.ToSlash(r[trim:])}
|
||||
if e.IsDir() {
|
||||
f.Type = "d"
|
||||
} else {
|
||||
|
||||
2
main.go
2
main.go
@@ -88,7 +88,7 @@ func main() {
|
||||
|
||||
srv := &http.Server{Addr: *addr}
|
||||
handleDefault := func(p string, h http.Handler) { http.Handle(p, realIP(*forwarded, h)) }
|
||||
handleLimited := func(p string, h http.Handler) { handleDefault(p, limit.Handler(logRequest(http.StripPrefix(p, fs)))) }
|
||||
handleLimited := func(p string, h http.Handler) { handleDefault(p, limit.Handler(logRequest(http.StripPrefix(p, h)))) }
|
||||
|
||||
handleLimited("/idx/", fs)
|
||||
handleLimited("/dl/", nodir(http.FileServer(http.Dir(fs.Root))))
|
||||
|
||||
Reference in New Issue
Block a user