Skip to content

Commit

Permalink
http: fix ParseURL to handle //relative_path properly
Browse files Browse the repository at this point in the history
Fixes #900.

R=rsc
CC=golang-dev
https://golang.org/cl/1756042
  • Loading branch information
adg committed Jul 12, 2010
1 parent 97bcf04 commit 880beaf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/pkg/http/url.go
Expand Up @@ -318,7 +318,7 @@ func ParseURL(rawurl string) (url *URL, err os.Error) {
}

// Maybe path is //authority/path
if len(path) > 2 && path[0:2] == "//" {
if url.Scheme != "" && len(path) > 2 && path[0:2] == "//" {
url.Authority, path = split(path[2:], '/', false)
}
url.RawPath = path + query
Expand Down
11 changes: 11 additions & 0 deletions src/pkg/http/url_test.go
Expand Up @@ -174,6 +174,17 @@ var urltests = []URLTest{
},
"",
},
// leading // without scheme shouldn't create an authority
URLTest{
"//foo",
&URL{
Raw: "//foo",
Scheme: "",
RawPath: "//foo",
Path: "//foo",
},
"",
},
}

var urlnofragtests = []URLTest{
Expand Down

0 comments on commit 880beaf

Please sign in to comment.