mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Fix
Signed-off-by: Marco Pracucci <marco@pracucci.com>
This commit is contained in:
parent
c28d940234
commit
5ae9c194ce
|
@ -533,7 +533,7 @@ func stringMatcherFromRegexpInternal(re *syntax.Regexp) StringMatcher {
|
|||
// we can optimize.
|
||||
switch {
|
||||
// Literal as prefix.
|
||||
case len(re.Sub) == 2 && re.Sub[0].Op == syntax.OpLiteral:
|
||||
case right == nil && len(re.Sub) == 2 && re.Sub[0].Op == syntax.OpLiteral:
|
||||
right = stringMatcherFromRegexpInternal(re.Sub[1])
|
||||
if right != nil {
|
||||
matches = []string{string(re.Sub[0].Rune)}
|
||||
|
@ -541,7 +541,7 @@ func stringMatcherFromRegexpInternal(re *syntax.Regexp) StringMatcher {
|
|||
}
|
||||
|
||||
// Literal as suffix.
|
||||
case len(re.Sub) == 2 && re.Sub[1].Op == syntax.OpLiteral:
|
||||
case left == nil && len(re.Sub) == 2 && re.Sub[1].Op == syntax.OpLiteral:
|
||||
left = stringMatcherFromRegexpInternal(re.Sub[0])
|
||||
if left != nil {
|
||||
matches = []string{string(re.Sub[1].Rune)}
|
||||
|
|
|
@ -413,6 +413,11 @@ func TestStringMatcherFromRegexp(t *testing.T) {
|
|||
// Case insensitive alternate with same literal prefix and .* suffix.
|
||||
{"(?i:(xyz-016a-ixb-dp.*|xyz-016a-ixb-op.*))", &literalPrefixStringMatcher{prefix: "XYZ-016A-IXB-", prefixCaseSensitive: false, right: orStringMatcher{&literalPrefixStringMatcher{prefix: "DP", prefixCaseSensitive: false, right: anyStringWithoutNewlineMatcher{}}, &literalPrefixStringMatcher{prefix: "OP", prefixCaseSensitive: false, right: anyStringWithoutNewlineMatcher{}}}}},
|
||||
{"(?i)(xyz-016a-ixb-dp.*|xyz-016a-ixb-op.*)", &literalPrefixStringMatcher{prefix: "XYZ-016A-IXB-", prefixCaseSensitive: false, right: orStringMatcher{&literalPrefixStringMatcher{prefix: "DP", prefixCaseSensitive: false, right: anyStringWithoutNewlineMatcher{}}, &literalPrefixStringMatcher{prefix: "OP", prefixCaseSensitive: false, right: anyStringWithoutNewlineMatcher{}}}}},
|
||||
// Concatenated variable length selectors are not supported.
|
||||
{"foo.*.*", nil},
|
||||
{"foo.+.+", nil},
|
||||
{".*.*foo", nil},
|
||||
{".+.+foo", nil},
|
||||
} {
|
||||
c := c
|
||||
t.Run(c.pattern, func(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue