From 01187fbce2362f25b434ded46695e3cd929602d8 Mon Sep 17 00:00:00 2001 From: Cyril Tovena Date: Mon, 11 Oct 2021 13:59:24 +0200 Subject: [PATCH] Review feedback Signed-off-by: Cyril Tovena --- pkg/labels/regexp.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/pkg/labels/regexp.go b/pkg/labels/regexp.go index 34bbceaca..69520970c 100644 --- a/pkg/labels/regexp.go +++ b/pkg/labels/regexp.go @@ -322,18 +322,17 @@ func stringMatcherFromRegexp(re *syntax.Regexp) StringMatcher { } // findSetMatches will returns only literals that are case sensitive. matches := findSetMatches(re, "") - if left == nil && right == nil { + if left == nil && right == nil && len(matches) > 0 { // if there's no any matchers on both side it's a concat of literals - if len(matches) > 0 { - or := make([]StringMatcher, 0, len(matches)) - for _, match := range matches { - or = append(or, &equalStringMatcher{ - s: match, - caseSensitive: true, - }) - } - return orStringMatcher(or) + + or := make([]StringMatcher, 0, len(matches)) + for _, match := range matches { + or = append(or, &equalStringMatcher{ + s: match, + caseSensitive: true, + }) } + return orStringMatcher(or) } // others we found literals in the middle. if len(matches) > 0 {