From c4d47340954d58b2f39759730ab9cd2fb6e22dbe Mon Sep 17 00:00:00 2001 From: Shun Zi Date: Sat, 27 Jun 2020 15:45:33 +0800 Subject: [PATCH] fix: GET directory fails when non-root prefix configured (#40) --- lib/webdav.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/webdav.go b/lib/webdav.go index 3fdb3c1..e8a864f 100755 --- a/lib/webdav.go +++ b/lib/webdav.go @@ -127,8 +127,8 @@ func (c *Config) ServeHTTP(w http.ResponseWriter, r *http.Request) { // the collection, or something else altogether. // // Get, when applied to collection, will return the same as PROPFIND method. - if r.Method == "GET" { - info, err := u.Handler.FileSystem.Stat(context.TODO(), r.URL.Path) + if r.Method == "GET" && strings.HasPrefix(r.URL.Path, u.Handler.Prefix) { + info, err := u.Handler.FileSystem.Stat(context.TODO(), strings.TrimPrefix(r.URL.Path, u.Handler.Prefix)) if err == nil && info.IsDir() { r.Method = "PROPFIND"