1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-24 08:25:23 +00:00

check init state of DomainMatcherGroup. fixes #1238

This commit is contained in:
Darien Raymond 2018-08-20 09:47:18 +02:00
parent fca324a399
commit 899b1399ee
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
2 changed files with 12 additions and 0 deletions

View File

@ -39,6 +39,10 @@ func (g *DomainMatcherGroup) Add(domain string, value uint32) {
func (g *DomainMatcherGroup) Match(domain string) uint32 {
current := g.root
if current == nil {
return 0
}
parts := breakDomain(domain)
for i := len(parts) - 1; i >= 0; i-- {
part := parts[i]

View File

@ -33,3 +33,11 @@ func TestDomainMatcherGroup(t *testing.T) {
}
}
}
func TestEmptyDomainMatcherGroup(t *testing.T) {
g := new(DomainMatcherGroup)
r := g.Match("v2ray.com")
if r != 0 {
t.Error("Expect 0, but ", r)
}
}