Add path to '/' if path is null string

This commit is contained in:
Harshavardhana
2015-07-29 23:27:18 -07:00
parent 59bf426abb
commit 68d72feeb7
2 changed files with 4 additions and 1 deletions
+1 -1
View File
@@ -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)
+3
View File
@@ -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{