aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Gerrand <adg@golang.org>2010-07-13 09:21:42 +1000
committerAndrew Gerrand <adg@golang.org>2010-07-13 09:21:42 +1000
commit880beafc9f60806597d143b71afd6da226367896 (patch)
treeb172ec4e9fc90c977bf6a41dba1adb5530e706f2
parent97bcf049f76441846ea190fcd41cd5cf0a8b2284 (diff)
downloadgo-880beafc9f60806597d143b71afd6da226367896.tar.gz
go-880beafc9f60806597d143b71afd6da226367896.zip
http: fix ParseURL to handle //relative_path properly
Fixes #900. R=rsc CC=golang-dev https://golang.org/cl/1756042
-rw-r--r--src/pkg/http/url.go2
-rw-r--r--src/pkg/http/url_test.go11
2 files changed, 12 insertions, 1 deletions
diff --git a/src/pkg/http/url.go b/src/pkg/http/url.go
index 148ada4b25..12247ca17b 100644
--- a/src/pkg/http/url.go
+++ b/src/pkg/http/url.go
@@ -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
diff --git a/src/pkg/http/url_test.go b/src/pkg/http/url_test.go
index 3d665100af..097669b9c2 100644
--- a/src/pkg/http/url_test.go
+++ b/src/pkg/http/url_test.go
@@ -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{