From 072d1f10ab41520207f5bb06adef1aa353afd98f Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 20 Feb 2024 10:31:11 +0000 Subject: [PATCH] serve webdav: fix --baseurl without leading / The webdav server needs the prefix passed to it with a leading / otherwise it does not remove it properly. The docs state that a leading slash is optional so this patch adds one if not present. See: https://forum.rclone.org/t/cant-rename-files-in-rclone-serve-webdav-with-baseurl-maybe-wrong-handling-of-move-request-method/44637 --- cmd/serve/webdav/webdav.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/serve/webdav/webdav.go b/cmd/serve/webdav/webdav.go index f482d13d5..e40eb6508 100644 --- a/cmd/serve/webdav/webdav.go +++ b/cmd/serve/webdav/webdav.go @@ -203,6 +203,9 @@ func newWebDAV(ctx context.Context, f fs.Fs, opt *Options) (w *WebDAV, err error return nil, fmt.Errorf("failed to init server: %w", err) } + // Make sure BaseURL starts with a / and doesn't end with one + w.opt.HTTP.BaseURL = "/" + strings.Trim(w.opt.HTTP.BaseURL, "/") + webdavHandler := &webdav.Handler{ Prefix: w.opt.HTTP.BaseURL, FileSystem: w,