1
0
mirror of https://github.com/alice-lg/alice-lg.git synced 2024-05-11 05:55:03 +00:00

fixed is prefix method

This commit is contained in:
Matthias Hannig
2018-12-16 16:29:57 +01:00
parent bd38ad0e84
commit 061a94d550
2 changed files with 4 additions and 1 deletions

View File

@ -8,6 +8,8 @@ import (
"time"
)
var REGEX_MATCH_IP_PREFIX = regexp.MustCompile(`([a-f0-9/]+[\.:]*)+`)
/*
Case Insensitive Contains
*/
@ -42,7 +44,7 @@ func MaybePrefix(s string) bool {
}
// Test using regex
matches := regexp.MustCompile(`([a-f0-9/]+[\.:]?)+`).FindAllStringIndex(s, -1)
matches := REGEX_MATCH_IP_PREFIX.FindAllStringIndex(s, -1)
if len(matches) == 1 {
return true
}

View File

@ -17,6 +17,7 @@ func TestMaybePrefix(t *testing.T) {
}{
{"10.0.0", true},
{"23.42.11.42/23", true},
{"fa42:2342::/32", true},
{"200", true},
{"2001:", true},
{"A", true},