diff --git a/cp-url-syntax.go b/cp-url-syntax.go index 046f61a9..1e522be7 100644 --- a/cp-url-syntax.go +++ b/cp-url-syntax.go @@ -45,8 +45,10 @@ func checkCopySyntax(ctx *cli.Context) { url := client.NewURL(tgtURL) if url.Host != "" { // This check is for type URL. - if url.Path == string(url.Separator) { - fatalIf(errInvalidArgument().Trace(), fmt.Sprintf("Target ‘%s’ does not contain bucket name.", tgtURL)) + if !isURLVirtualHostStyle(url.Host) { + if url.Path == string(url.Separator) { + fatalIf(errInvalidArgument().Trace(), fmt.Sprintf("Target ‘%s’ does not contain bucket name.", tgtURL)) + } } } diff --git a/mirror-url.go b/mirror-url.go index 9670cdea..7ab94ff4 100644 --- a/mirror-url.go +++ b/mirror-url.go @@ -75,9 +75,11 @@ func checkMirrorSyntax(ctx *cli.Context) { url := client.NewURL(tgtURL) if url.Host != "" { - if url.Path == string(url.Separator) { - fatalIf(errInvalidArgument().Trace(tgtURL), - fmt.Sprintf("Target ‘%s’ does not contain bucket name.", tgtURL)) + if !isURLVirtualHostStyle(url.Host) { + if url.Path == string(url.Separator) { + fatalIf(errInvalidArgument().Trace(tgtURL), + fmt.Sprintf("Target ‘%s’ does not contain bucket name.", tgtURL)) + } } } _, _, err = url2Stat(tgtURL) diff --git a/url.go b/url.go index ff1136b0..72734cf6 100644 --- a/url.go +++ b/url.go @@ -17,10 +17,18 @@ package main import ( + "path/filepath" + "github.com/minio/mc/pkg/client" "github.com/minio/minio-xl/pkg/probe" ) +func isURLVirtualHostStyle(hostURL string) bool { + matchS3, _ := filepath.Match("*.s3*.amazonaws.com", hostURL) + matchGoogle, _ := filepath.Match("*.storage.googleapis.com", hostURL) + return matchS3 || matchGoogle +} + // urlJoinPath Join a path to existing URL. func urlJoinPath(url1, url2 string) string { u1 := client.NewURL(url1)