mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 00:34:24 -04:00
Use dns.IsSubDomain (#112)
For the match function use the proper thing from go dns. Fix all callers and tests to use this. Fixes: #107
This commit is contained in:
@@ -9,13 +9,14 @@ import (
|
||||
// Name represents a domain name.
|
||||
type Name string
|
||||
|
||||
// Matches checks to see if other matches n.
|
||||
//
|
||||
// Name matching will probably not always be a direct
|
||||
// comparison; this method assures that names can be
|
||||
// easily and consistently matched.
|
||||
func (n Name) Matches(other string) bool {
|
||||
return strings.HasSuffix(string(n), other)
|
||||
// Matches checks to see if other is a subdomain (or the same domain) of n.
|
||||
// This method assures that names can be easily and consistently matched.
|
||||
func (n Name) Matches(child string) bool {
|
||||
if dns.Name(n) == dns.Name(child) {
|
||||
return true
|
||||
}
|
||||
|
||||
return dns.IsSubDomain(string(n), child)
|
||||
}
|
||||
|
||||
// Normalize lowercases and makes n fully qualified.
|
||||
|
||||
Reference in New Issue
Block a user