diff --git a/pkg/client/client_test.go b/pkg/client/client_test.go index 6862ca89..66fce181 100644 --- a/pkg/client/client_test.go +++ b/pkg/client/client_test.go @@ -33,7 +33,7 @@ func (s *MySuite) TestURLParse(c *C) { c.Assert(err, IsNil) c.Assert(u.Scheme, Equals, "http") c.Assert(u.Host, Equals, "s3.example.com") - c.Assert(u.Path, Equals, "") + c.Assert(u.Path, Equals, "/") u, err = Parse("http://s3.example.com/path/new") c.Assert(err, IsNil) diff --git a/pkg/client/url.go b/pkg/client/url.go index 2468b798..b58abb99 100644 --- a/pkg/client/url.go +++ b/pkg/client/url.go @@ -90,6 +90,9 @@ func Parse(urlStr string) (*URL, error) { if strings.HasPrefix(rest, "//") { // if rest has '//' prefix, skip them authority, rest := splitSpecial(rest[2:], "/", false) + if rest == "" { + rest = "/" + } host := getHost(authority) if host != "" && (scheme == "http" || scheme == "https") { return &URL{