From: Andrew Gerrand Date: Mon, 12 Jul 2010 23:21:42 +0000 (+1000) Subject: http: fix ParseURL to handle //relative_path properly X-Git-Tag: weekly.2010-07-14~27 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=880beafc9f60806597d143b71afd6da226367896;p=gostls13.git http: fix ParseURL to handle //relative_path properly Fixes #900. R=rsc CC=golang-dev https://golang.org/cl/1756042 --- 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{