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:
parent
97bcf049f7
commit
880beafc9f
@ -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{
|
||||
|
Loading…
Reference in New Issue
Block a user