fixed wrongfully assumed v6 prefix
This commit is contained in:
parent
130db6c0f4
commit
07092b51bc
@ -27,6 +27,11 @@ func MaybePrefix(s string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Must contain at least one dot or colon
|
||||||
|
if !strings.Contains(s, ":") && !strings.Contains(s, ".") {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// Test using regex
|
// Test using regex
|
||||||
matches := ReMatchIPPrefix.FindAllStringIndex(s, -1)
|
matches := ReMatchIPPrefix.FindAllStringIndex(s, -1)
|
||||||
if len(matches) == 1 {
|
if len(matches) == 1 {
|
||||||
|
@ -12,9 +12,11 @@ func TestMaybePrefix(t *testing.T) {
|
|||||||
{"10.0.0", true},
|
{"10.0.0", true},
|
||||||
{"23.42.11.42/23", true},
|
{"23.42.11.42/23", true},
|
||||||
{"fa42:2342::/32", true},
|
{"fa42:2342::/32", true},
|
||||||
{"200", true},
|
{"1.", true},
|
||||||
|
{"200", false},
|
||||||
|
{"200.", true},
|
||||||
{"2001:", true},
|
{"2001:", true},
|
||||||
{"A", true},
|
{"A", false},
|
||||||
{"A b", false},
|
{"A b", false},
|
||||||
{"23 Foo", false},
|
{"23 Foo", false},
|
||||||
{"Nordfoo", false},
|
{"Nordfoo", false},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user