diff --git a/cp-url.go b/cp-url.go index 776215c0..7b70331e 100644 --- a/cp-url.go +++ b/cp-url.go @@ -290,11 +290,10 @@ func prepareCopyURLsTypeC(sourceURL, targetURL string) <-chan copyURLs { } // All OK.. We can proceed. Type B: source is a file, target is a folder and exists. - newTargetURL := client.NewURL(targetURL) - newTargetURL.Path = filepath.Join(newTargetURL.Path, - strings.TrimPrefix(sourceContent.Content.URL.Path, url2Dir(sourceURL))) - - copyURLsCh <- prepareCopyURLsTypeA(sourceContent.Content.URL.String(), newTargetURL.String()) + newSourceURL := sourceContent.Content.URL.String() + newSourceSuffix := strings.TrimPrefix(newSourceURL, sourceURL) + newTargetURL := urlJoinPath(targetURL, newSourceSuffix) + copyURLsCh <- prepareCopyURLsTypeA(sourceContent.Content.URL.String(), newTargetURL) } }(sourceURL, targetURL, copyURLsCh) return copyURLsCh diff --git a/url.go b/url.go index c0c48e8f..91fbcf5d 100644 --- a/url.go +++ b/url.go @@ -29,20 +29,6 @@ const ( recursiveSeparator = "..." ) -// just like filepath.Dir but always has a trailing url.Seperator -func url2Dir(urlStr string) string { - url := client.NewURL(urlStr) - if strings.HasSuffix(urlStr, string(url.Separator)) { - return urlStr - } - lastIndex := strings.LastIndex(urlStr, string(url.Separator)) - dirname := urlStr[:lastIndex+1] - if dirname == "" { - return "." - } - return dirname -} - // urlJoinPath Join a path to existing URL. func urlJoinPath(url1, url2 string) string { u1 := client.NewURL(url1)