Case insensitivity when comparing targets

This commit is contained in:
Rob Selway 2021-02-14 13:40:25 +00:00
parent 6a7fb3a9a7
commit 0a9daa9e9b
2 changed files with 3 additions and 2 deletions

View File

@ -71,7 +71,7 @@ func (t Targets) Swap(i, j int) {
t[i], t[j] = t[j], t[i]
}
// Same compares to Targets and returns true if they are completely identical
// Same compares to Targets and returns true if they are identical (case-insensitive)
func (t Targets) Same(o Targets) bool {
if len(t) != len(o) {
return false
@ -80,7 +80,7 @@ func (t Targets) Same(o Targets) bool {
sort.Stable(o)
for i, e := range t {
if e != o[i] {
if !strings.EqualFold(e, o[i]) {
return false
}
}

View File

@ -40,6 +40,7 @@ func TestTargetsSame(t *testing.T) {
{""},
{"1.2.3.4"},
{"8.8.8.8", "8.8.4.4"},
{"example.org", "EXAMPLE.ORG"},
}
for _, d := range tests {