fix: align direct file serving with CHFS routes
This commit is contained in:
@@ -564,6 +564,10 @@ func (s *Server) shared(w http.ResponseWriter, r *http.Request) {
|
|||||||
_, _ = io.WriteString(w, "</pre>\n")
|
_, _ = io.WriteString(w, "</pre>\n")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if r.Method != http.MethodGet {
|
||||||
|
http.NotFound(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
f, err := s.Store.Open(p)
|
f, err := s.Store.Open(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.NotFound(w, r)
|
http.NotFound(w, r)
|
||||||
@@ -611,20 +615,7 @@ func (s *Server) preview(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) fileHandler(w http.ResponseWriter, r *http.Request) {
|
func (s *Server) fileHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.URL.Path == "/" || strings.HasPrefix(r.URL.Path, "/asset/") {
|
http.NotFound(w, r)
|
||||||
http.NotFound(w, r)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if strings.HasPrefix(r.URL.Path, "/chfs/") || r.URL.Path == "/webdav" {
|
|
||||||
http.NotFound(w, r)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
p := strings.Trim(strings.ReplaceAll(r.URL.Path, "\\", "/"), "/")
|
|
||||||
if p == "" {
|
|
||||||
http.NotFound(w, r)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.serveFile(w, r, p, false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) serveFile(w http.ResponseWriter, r *http.Request, p string, attachment bool) {
|
func (s *Server) serveFile(w http.ResponseWriter, r *http.Request, p string, attachment bool) {
|
||||||
|
|||||||
Reference in New Issue
Block a user