Fix ensureParent method to correctly handle baseURL and cur path separators
This commit is contained in:
BIN
go_cloud/bin/api
BIN
go_cloud/bin/api
Binary file not shown.
@@ -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 != "" {
|
||||
|
||||
Reference in New Issue
Block a user