mirror of
https://github.com/caddyserver/caddy.git
synced 2025-04-19 18:58:50 +08:00
update test cases (!!!)
This commit is contained in:
parent
110b58a255
commit
de85a8ba3d
@ -390,10 +390,13 @@ func SplitNetworkAddress(a string) (network, host, port string, err error) {
|
||||
firstErr := err
|
||||
|
||||
if err != nil {
|
||||
a = strings.TrimPrefix(a, "[") // IPv6
|
||||
a = strings.TrimSuffix(a, "]")
|
||||
// in general, if there was an error, it was likely "missing port",
|
||||
// so try adding a bogus port to take advantage of standard library's
|
||||
// robust parser.
|
||||
// robust parser, then strip the artificial port.
|
||||
host, _, err = net.SplitHostPort(net.JoinHostPort(a, "0"))
|
||||
port = ""
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
@ -31,7 +31,7 @@ func TestSplitNetworkAddress(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
input: "",
|
||||
expectErr: true,
|
||||
expectHost: "",
|
||||
},
|
||||
{
|
||||
input: "foo",
|
||||
@ -42,7 +42,7 @@ func TestSplitNetworkAddress(t *testing.T) {
|
||||
},
|
||||
{
|
||||
input: "::",
|
||||
expectErr: true,
|
||||
expectHost: "::",
|
||||
},
|
||||
{
|
||||
input: "[::]",
|
||||
@ -77,7 +77,7 @@ func TestSplitNetworkAddress(t *testing.T) {
|
||||
{
|
||||
input: "udp/",
|
||||
expectNetwork: "udp",
|
||||
expectErr: true,
|
||||
expectHost: "",
|
||||
},
|
||||
{
|
||||
input: "unix//foo/bar",
|
||||
@ -185,7 +185,8 @@ func TestParseNetworkAddress(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
input: "",
|
||||
expectErr: true,
|
||||
expectAddr: NetworkAddress{
|
||||
},
|
||||
},
|
||||
{
|
||||
input: ":",
|
||||
@ -311,7 +312,8 @@ func TestParseNetworkAddressWithDefaults(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
input: "",
|
||||
expectErr: true,
|
||||
expectAddr: NetworkAddress{
|
||||
},
|
||||
},
|
||||
{
|
||||
input: ":",
|
||||
|
Loading…
x
Reference in New Issue
Block a user