1
0
mirror of https://github.com/golang/go synced 2024-11-19 21:04:43 -07:00

http: fix ParseURL to handle //relative_path properly

Fixes #900.

R=rsc
CC=golang-dev
https://golang.org/cl/1756042
This commit is contained in:
Andrew Gerrand 2010-07-13 09:21:42 +10:00
parent 97bcf049f7
commit 880beafc9f
2 changed files with 12 additions and 1 deletions

View File

@ -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

View File

@ -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{