Skip to content

Commit d5e0c06

Browse files
authored
allow for blank ip addresses (spf13#316)
1 parent 85dd5c8 commit d5e0c06

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

ip.go

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ func newIPValue(val net.IP, p *net.IP) *ipValue {
1616

1717
func (i *ipValue) String() string { return net.IP(*i).String() }
1818
func (i *ipValue) Set(s string) error {
19+
if s == "" {
20+
return nil
21+
}
1922
ip := net.ParseIP(strings.TrimSpace(s))
2023
if ip == nil {
2124
return fmt.Errorf("failed to parse IP: %q", s)

ip_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func TestIP(t *testing.T) {
2424
{"1.2.3.4", true, "1.2.3.4"},
2525
{"127.0.0.1", true, "127.0.0.1"},
2626
{"255.255.255.255", true, "255.255.255.255"},
27-
{"", false, ""},
27+
{"", true, "0.0.0.0"},
2828
{"0", false, ""},
2929
{"localhost", false, ""},
3030
{"0.0.0", false, ""},

0 commit comments

Comments
 (0)