}
return host1 + host2 + host3, nil
}
+ } else if i := strings.LastIndex(host, ":"); i > 0 {
+ colonPort := host[i:]
+ if !validOptionalPort(colonPort) {
+ return "", fmt.Errorf("invalid port %q after host", colonPort)
+ }
}
-
var err error
if host, err = unescape(host, encodeHost); err != nil {
return "", err
},
// worst case host, still round trips
{
- "scheme://!$&'()*+,;=hello!:port/path",
+ "scheme://!$&'()*+,;=hello!:8080/path",
&URL{
Scheme: "scheme",
- Host: "!$&'()*+,;=hello!:port",
+ Host: "!$&'()*+,;=hello!:8080",
Path: "/path",
},
"",
{"*", true},
{"http://192.168.0.1/", true},
{"http://192.168.0.1:8080/", true},
+ {"http://192.168.0.1:foo/", false},
{"http://[fe80::1]/", true},
{"http://[fe80::1]:8080/", true},
+ {"http://[fe80::1]:foo/", false},
// Tests exercising RFC 6874 compliance:
{"http://[fe80::1%25en0]/", true}, // with alphanum zone identifier