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:
@ -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
|
||||
}
|
||||
|
@ -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},
|
||||
|
Reference in New Issue
Block a user