1
0
mirror of https://github.com/zu1k/nali.git synced 2025-01-22 13:19:02 +08:00
nali/pkg/re/re_test.go
zu1k 6bf5d94920 fix: CDN support regex
Signed-off-by: zu1k <i@zu1k.com>
2022-06-29 17:00:34 +08:00

56 lines
895 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package re
import (
"fmt"
"testing"
)
var domainList = []string{
"a.a.qiniudns.com",
"a.com.qiniudns.com",
"a.com.cn.qiniudns.com",
"看这里a.com.cn.qiniudns.com行不行",
}
func TestDomainRe(t *testing.T) {
for _, domain := range domainList {
if !DomainRe.MatchString(domain) {
t.Error(domain)
t.Fail()
}
fmt.Println(DomainRe.FindAllString(domain, -1))
}
}
var validIPv6List = []string{
"::ffff:104.26.11.119",
}
func TestIPv6Re(t *testing.T) {
for _, ip := range validIPv6List {
if !IPv6Re.MatchString(ip) {
t.Error(ip)
t.Fail()
}
fmt.Println(IPv6Re.FindAllString(ip, -1))
}
}
var maybeRegexList = []string{
"[a-z]*\\.example.com",
"kunlun[^.]+.com",
"gtm-a[1-7]b[1-9].com",
}
func TestMaybeRegexp(t *testing.T) {
if MaybeRegexp("abc.com") {
t.Fail()
}
for _, str := range maybeRegexList {
if !MaybeRegexp(str) {
t.Fail()
}
}
}