diff options
author | Andrew Gerrand <adg@golang.org> | 2010-07-13 09:21:42 +1000 |
---|---|---|
committer | Andrew Gerrand <adg@golang.org> | 2010-07-13 09:21:42 +1000 |
commit | 880beafc9f60806597d143b71afd6da226367896 (patch) | |
tree | b172ec4e9fc90c977bf6a41dba1adb5530e706f2 | |
parent | 97bcf049f76441846ea190fcd41cd5cf0a8b2284 (diff) | |
download | go-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.go | 2 | ||||
-rw-r--r-- | src/pkg/http/url_test.go | 11 |
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{ |