Fix: domain trie should backtrack to parent if match fail (#758)

This commit is contained in:
Kr328
2020-06-24 18:41:23 +08:00
committed by GitHub
parent 5f3db72422
commit 3dfff84cc3
2 changed files with 30 additions and 33 deletions

View File

@ -39,6 +39,10 @@ func TestTrie_Wildcard(t *testing.T) {
".example.net",
".apple.*",
"+.foo.com",
"+.stun.*.*",
"+.stun.*.*.*",
"+.stun.*.*.*.*",
"stun.l.google.com",
}
for _, domain := range domains {
@ -52,6 +56,7 @@ func TestTrie_Wildcard(t *testing.T) {
assert.NotNil(t, tree.Search("test.apple.com"))
assert.NotNil(t, tree.Search("test.foo.com"))
assert.NotNil(t, tree.Search("foo.com"))
assert.NotNil(t, tree.Search("global.stun.website.com"))
assert.Nil(t, tree.Search("foo.sub.example.com"))
assert.Nil(t, tree.Search("foo.example.dev"))
assert.Nil(t, tree.Search("example.com"))