Fix ensureParent method to correctly handle baseURL and cur path separators

This commit is contained in:
Leon Bösche
2026-01-29 03:48:04 +01:00
parent b6a9e2aa54
commit 62a23b5fb0
2 changed files with 6 additions and 1 deletions

Binary file not shown.

View File

@@ -59,7 +59,12 @@ func (c *WebDAVClient) ensureParent(ctx context.Context, remotePath string) erro
if cur == "" || cur == "/" {
mkurl = fmt.Sprintf("%s/%s", c.baseURL, url.PathEscape(p))
} else {
mkurl = fmt.Sprintf("%s%s", c.baseURL, cur)
// Ensure there's a "/" between baseURL and cur
sep := ""
if !strings.HasSuffix(c.baseURL, "/") && !strings.HasPrefix(cur, "/") {
sep = "/"
}
mkurl = fmt.Sprintf("%s%s%s", c.baseURL, sep, strings.TrimPrefix(cur, "/"))
}
req, _ := http.NewRequestWithContext(ctx, "MKCOL", mkurl, nil)
if c.user != "" {