Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

azureblob,b2,qingstor,s3,swift: remove leading / from paths - fixes #2484

Nick Craig-Wood7194c358ad7b
diff --git a/backend/azureblob/azureblob.go b/backend/azureblob/azureblob.go
index 6d5a76d3a..bd3f5211d 100644
--- a/backend/azureblob/azureblob.go
+++ b/backend/azureblob/azureblob.go
@@ -157,7 +157,7 @@ func (f *Fs) Features() *fs.Features {
}
// Pattern to match a azure path
-var matcher = regexp.MustCompile(`^([^/]*)(.*)$`)
+var matcher = regexp.MustCompile(`^/*([^/]*)(.*)$`)
// parseParse parses a azure 'url'
func parsePath(path string) (container, directory string, err error) {
diff --git a/backend/b2/b2.go b/backend/b2/b2.go
index 1908fca25..ab9c6db8c 100644
--- a/backend/b2/b2.go
+++ b/backend/b2/b2.go
@@ -177,7 +177,7 @@ func (f *Fs) Features() *fs.Features {
}
// Pattern to match a b2 path
-var matcher = regexp.MustCompile(`^([^/]*)(.*)$`)
+var matcher = regexp.MustCompile(`^/*([^/]*)(.*)$`)
// parseParse parses a b2 'url'
func parsePath(path string) (bucket, directory string, err error) {
diff --git a/backend/qingstor/qingstor.go b/backend/qingstor/qingstor.go
index b5ca24e04..bb3627403 100644
--- a/backend/qingstor/qingstor.go
+++ b/backend/qingstor/qingstor.go
@@ -132,10 +132,12 @@ type Object struct {
// ------------------------------------------------------------
+// Pattern to match a qingstor path
+var matcher = regexp.MustCompile(`^/*([^/]*)(.*)$`)
+
// parseParse parses a qingstor 'url'
func qsParsePath(path string) (bucket, key string, err error) {
// Pattern to match a qingstor path
- var matcher = regexp.MustCompile(`^([^/]*)(.*)$`)
parts := matcher.FindStringSubmatch(path)
if parts == nil {
err = errors.Errorf("Couldn't parse bucket out of qingstor path %q", path)
diff --git a/backend/s3/s3.go b/backend/s3/s3.go
index db8294ba6..17463e4fa 100644
--- a/backend/s3/s3.go
+++ b/backend/s3/s3.go
@@ -635,7 +635,7 @@ func (f *Fs) Features() *fs.Features {
}
// Pattern to match a s3 path
-var matcher = regexp.MustCompile(`^([^/]*)(.*)$`)
+var matcher = regexp.MustCompile(`^/*([^/]*)(.*)$`)
// parseParse parses a s3 'url'
func s3ParsePath(path string) (bucket, directory string, err error) {
diff --git a/backend/swift/swift.go b/backend/swift/swift.go
index 65856a327..57c008307 100644
--- a/backend/swift/swift.go
+++ b/backend/swift/swift.go
@@ -216,7 +216,7 @@ func (f *Fs) Features() *fs.Features {
}
// Pattern to match a swift path
-var matcher = regexp.MustCompile(`^([^/]*)(.*)$`)
+var matcher = regexp.MustCompile(`^/*([^/]*)(.*)$`)
// parseParse parses a swift 'url'
func parsePath(path string) (container, directory string, err error) {