serve webdav: fix --baseurl handling after lib/http refactor

The webdav library was confused by the Path manipulation done by
lib/http when stripping the prefix.

This patch adds the prefix back before calling it.

Fixes #6650
This commit is contained in:
Nick Craig-Wood 2022-12-22 15:42:47 +00:00
parent 54c0f17f2a
commit 6257a6035c
2 changed files with 4 additions and 0 deletions

View File

@ -237,6 +237,9 @@ func (w *WebDAV) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
w.serveDir(rw, r, remote)
return
}
// Add URL Prefix back to path since webdavhandler needs to
// return absolute references.
r.URL.Path = w.opt.HTTP.BaseURL + r.URL.Path
w.webdavhandler.ServeHTTP(rw, r)
}

View File

@ -51,6 +51,7 @@ func TestWebDav(t *testing.T) {
start := func(f fs.Fs) (configmap.Simple, func()) {
opt := DefaultOpt
opt.HTTP.ListenAddr = []string{testBindAddress}
opt.HTTP.BaseURL = "/prefix"
opt.Auth.BasicUser = testUser
opt.Auth.BasicPass = testPass
opt.Template.Path = testTemplate