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{