Commit 880beafc authored by Andrew Gerrand's avatar Andrew Gerrand

http: fix ParseURL to handle //relative_path properly

Fixes #900.

R=rsc
CC=golang-dev
https://golang.org/cl/1756042
parent 97bcf049
......@@ -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
......
......@@ -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{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment