Unverified Commit 79ca84a9 authored by Nick Jüttner's avatar Nick Jüttner Committed by GitHub
Browse files

Revert "Fix domain-filter matching logic to not match similar domain names"

No related merge requests found
Showing with 1 addition and 40 deletions
+1 -40
......@@ -46,17 +46,8 @@ func (df DomainFilter) Match(domain string) bool {
}
for _, filter := range df.filters {
strippedDomain := strings.TrimSuffix(domain, ".")
if filter == "" {
return true
} else if strings.HasPrefix(filter, ".") && strings.HasSuffix(strippedDomain, filter) {
return true
} else if strings.Count(strippedDomain, ".") == strings.Count(filter, ".") {
if strippedDomain == filter {
return true
}
} else if strings.HasSuffix(strippedDomain, "."+filter) {
if strings.HasSuffix(strings.TrimSuffix(domain, "."), filter) {
return true
}
}
......
......@@ -99,36 +99,6 @@ var domainFilterTests = []domainFilterTest{
[]string{"foo.bar.sub.example.org"},
true,
},
{
[]string{"example.org"},
[]string{"anexample.org", "test.anexample.org"},
false,
},
{
[]string{".example.org"},
[]string{"anexample.org", "test.anexample.org"},
false,
},
{
[]string{".example.org"},
[]string{"example.org"},
false,
},
{
[]string{".example.org"},
[]string{"test.example.org"},
true,
},
{
[]string{"anexample.org"},
[]string{"example.org", "test.example.org"},
false,
},
{
[]string{".org"},
[]string{"example.org", "test.example.org", "foo.test.example.org"},
true,
},
}
func TestDomainFilterMatch(t *testing.T) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment