Fixes #20054
Change-Id: I3c660ca0c56cdde2c2ac2f6a666d8531ab5588c5
Reviewed-on: https://go-review.googlesource.com/49050
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
buf.WriteString(u.Opaque)
} else {
if u.Scheme != "" || u.Host != "" || u.User != nil {
- buf.WriteString("//")
+ if u.Host != "" || u.Path != "" || u.User != nil {
+ buf.WriteString("//")
+ }
if ui := u.User; ui != nil {
buf.WriteString(ui.String())
buf.WriteByte('@')
},
"",
},
+ // test we can roundtrip magnet url
+ // fix issue https://golang.org/issue/20054
+ {
+ "magnet:?xt=urn:btih:c12fe1c06bba254a9dc9f519b335aa7c1367a88a&dn",
+ &URL{
+ Scheme: "magnet",
+ Host: "",
+ Path: "",
+ RawQuery: "xt=urn:btih:c12fe1c06bba254a9dc9f519b335aa7c1367a88a&dn",
+ },
+ "magnet:?xt=urn:btih:c12fe1c06bba254a9dc9f519b335aa7c1367a88a&dn",
+ },
+ {
+ "mailto:?subject=hi",
+ &URL{
+ Scheme: "mailto",
+ Host: "",
+ Path: "",
+ RawQuery: "subject=hi",
+ },
+ "mailto:?subject=hi",
+ },
}
// more useful string for debugging than fmt's struct printer