diff --git a/util/fields/fields.go b/util/fields/fields.go index bece2f900596..0b5849c674bd 100644 --- a/util/fields/fields.go +++ b/util/fields/fields.go @@ -60,7 +60,7 @@ func (f Cleaner) WillExclude(x string) bool { func (f Cleaner) matches(x string) bool { for y := range f.fields { - if strings.HasPrefix(x, y) { + if strings.HasPrefix(x, y) || strings.HasPrefix(y, x) { return true } } diff --git a/util/fields/fields_test.go b/util/fields/fields_test.go index 4961920c0805..d20a3c760f40 100644 --- a/util/fields/fields_test.go +++ b/util/fields/fields_test.go @@ -28,6 +28,8 @@ func TestCleaner_WillExclude(t *testing.T) { assert.False(t, NewCleaner("foo").WillExclude("foo")) assert.False(t, NewCleaner("foo").WillExclude("foo.bar")) assert.True(t, NewCleaner("foo").WillExclude("bar")) + assert.False(t, NewCleaner("foo.bar.baz").WillExclude("foo.bar")) + }) t.Run("Exclude", func(t *testing.T) { assert.True(t, NewCleaner("-foo").WillExclude("foo"))