From 68d72feeb7000c0a8880b0f0ccc1bf9ab8ac49bc Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 29 Jul 2015 23:26:35 -0700 Subject: [PATCH] Add path to '/' if path is null string --- pkg/client/client_test.go | 2 +- pkg/client/url.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) 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{