}
}
- if (url.Scheme != "" || !viaRequest) && strings.HasPrefix(rest, "//") && !strings.HasPrefix(rest, "///") {
+ if (url.Scheme != "" || !viaRequest && !strings.HasPrefix(rest, "///")) && strings.HasPrefix(rest, "//") {
var authority string
authority, rest = split(rest[2:], '/', false)
url.User, url.Host, err = parseAuthority(authority)
if u.Opaque != "" {
result += u.Opaque
} else {
- if u.Host != "" || u.User != nil {
+ if u.Scheme != "" || u.Host != "" || u.User != nil {
result += "//"
if u := u.User; u != nil {
result += u.String() + "@"
}
- result += u.Host
+ if h := u.Host; h != "" {
+ result += u.Host
+ }
}
result += escape(u.Path, encodePath)
}
},
"http:%2f%2fwww.google.com/?q=go+language",
},
- // non-authority
+ // non-authority with path
{
"mailto:/webmaster@golang.org",
&URL{
Scheme: "mailto",
Path: "/webmaster@golang.org",
},
- "",
+ "mailto:///webmaster@golang.org", // unfortunate compromise
},
// non-authority
{
},
"http://www.google.com/?q=go+language#foo&bar",
},
+ {
+ "file:///home/adg/rabbits",
+ &URL{
+ Scheme: "file",
+ Host: "",
+ Path: "/home/adg/rabbits",
+ },
+ "file:///home/adg/rabbits",
+ },
}
// more useful string for debugging than fmt's struct printer