mirror of
https://github.com/nxtrace/nali
synced 2024-11-23 02:38:11 +00:00
fix domain re
This commit is contained in:
parent
8319d3591d
commit
710597802b
@ -7,10 +7,8 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/zu1k/nali/internal/tools"
|
||||
|
||||
"github.com/zu1k/nali/constant"
|
||||
|
||||
"github.com/zu1k/nali/internal/tools"
|
||||
"github.com/zu1k/nali/pkg/cdn"
|
||||
)
|
||||
|
||||
@ -20,7 +18,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
domainRe = regexp.MustCompile(`[0-9A-Za-z]{2,}\.[0-9A-Za-z]{2,3}\.[0-9A-Za-z]{2,3}|[0-9A-Za-z]{2,}\.[0-9A-Za-z]{2,3}`)
|
||||
domainRe = regexp.MustCompile(`[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+`)
|
||||
}
|
||||
|
||||
func InitCDNDB() {
|
||||
|
23
internal/app/re_test.go
Normal file
23
internal/app/re_test.go
Normal file
@ -0,0 +1,23 @@
|
||||
package app
|
||||
|
||||
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))
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user