From 94737cb0374ea474a1e83b02706bb3875464108b Mon Sep 17 00:00:00 2001 From: Dimitrij Drus Date: Tue, 13 Dec 2022 02:29:42 +0100 Subject: [PATCH] fix for header matcher --- .../pipeline/errorhandlers/matcher/header_matcher.go | 10 +++++++--- .../errorhandlers/matcher/header_matcher_test.go | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/internal/pipeline/errorhandlers/matcher/header_matcher.go b/internal/pipeline/errorhandlers/matcher/header_matcher.go index 3613d5aba..8596812bf 100644 --- a/internal/pipeline/errorhandlers/matcher/header_matcher.go +++ b/internal/pipeline/errorhandlers/matcher/header_matcher.go @@ -1,7 +1,7 @@ package matcher import ( - "golang.org/x/exp/slices" + "strings" ) type HeaderMatcher map[string][]string @@ -9,8 +9,12 @@ type HeaderMatcher map[string][]string func (hm HeaderMatcher) Match(headers map[string]string) bool { for name, valueList := range hm { headerVal, found := headers[name] - if found && slices.Contains(valueList, headerVal) { - return true + if found { + for _, val := range valueList { + if strings.Contains(headerVal, val) { + return true + } + } } } diff --git a/internal/pipeline/errorhandlers/matcher/header_matcher_test.go b/internal/pipeline/errorhandlers/matcher/header_matcher_test.go index 251bc9764..1d13d97bf 100644 --- a/internal/pipeline/errorhandlers/matcher/header_matcher_test.go +++ b/internal/pipeline/errorhandlers/matcher/header_matcher_test.go @@ -20,7 +20,7 @@ func TestHeaderMatcher(t *testing.T) { headers: map[string][]string{ "foobar": {"foo", "bar"}, }, - match: map[string]string{"foobar": "bar"}, + match: map[string]string{"foobar": "bar,baz"}, matching: true, }, { @@ -30,8 +30,8 @@ func TestHeaderMatcher(t *testing.T) { "some-header": {"value1", "value2"}, }, match: map[string]string{ - "foobar": "bar", - "some-header": "value1", + "foobar": "bar,foo", + "some-header": "value1,val3", }, matching: true, },