diff options
| author | David Rivera <[email protected]> | 2021-06-04 12:30:23 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-06-04 12:30:23 -0700 |
| commit | d5e0c0615acee7028e1e2740a11102313be88de1 (patch) | |
| tree | 39d64ee9360352d5375bef758f25d423010f67f7 | |
| parent | 85dd5c8bc61cfa382fecd072378089d4e856579d (diff) | |
allow for blank ip addresses (#316)
| -rw-r--r-- | ip.go | 3 | ||||
| -rw-r--r-- | ip_test.go | 2 |
2 files changed, 4 insertions, 1 deletions
@@ -16,6 +16,9 @@ func newIPValue(val net.IP, p *net.IP) *ipValue { func (i *ipValue) String() string { return net.IP(*i).String() } func (i *ipValue) Set(s string) error { + if s == "" { + return nil + } ip := net.ParseIP(strings.TrimSpace(s)) if ip == nil { return fmt.Errorf("failed to parse IP: %q", s) @@ -24,7 +24,7 @@ func TestIP(t *testing.T) { {"1.2.3.4", true, "1.2.3.4"}, {"127.0.0.1", true, "127.0.0.1"}, {"255.255.255.255", true, "255.255.255.255"}, - {"", false, ""}, + {"", true, "0.0.0.0"}, {"0", false, ""}, {"localhost", false, ""}, {"0.0.0", false, ""}, |
