mirror of https://github.com/v2ray/v2ray-core
check init state of DomainMatcherGroup. fixes #1238
parent
fca324a399
commit
899b1399ee
|
@ -39,6 +39,10 @@ func (g *DomainMatcherGroup) Add(domain string, value uint32) {
|
||||||
|
|
||||||
func (g *DomainMatcherGroup) Match(domain string) uint32 {
|
func (g *DomainMatcherGroup) Match(domain string) uint32 {
|
||||||
current := g.root
|
current := g.root
|
||||||
|
if current == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
parts := breakDomain(domain)
|
parts := breakDomain(domain)
|
||||||
for i := len(parts) - 1; i >= 0; i-- {
|
for i := len(parts) - 1; i >= 0; i-- {
|
||||||
part := parts[i]
|
part := parts[i]
|
||||||
|
|
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue