Skip to content

Commit 979ec08

Browse files
Plugin: Change rewriteTargetWithoutCaptureGroup lint to include any numbered capture group. (#13932)
Co-authored-by: Dan <[email protected]>
1 parent 9b6dcad commit 979ec08

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

cmd/plugin/lints/ingress.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package lints
1818

1919
import (
2020
"fmt"
21+
"regexp"
2122
"strings"
2223

2324
networking "k8s.io/api/networking/v1"
@@ -126,7 +127,7 @@ func annotationPrefixIsNginxOrg(ing *networking.Ingress) bool {
126127

127128
func rewriteTargetWithoutCaptureGroup(ing *networking.Ingress) bool {
128129
for name, val := range ing.Annotations {
129-
if strings.HasSuffix(name, "/rewrite-target") && !strings.Contains(val, "$1") {
130+
if strings.HasSuffix(name, "/rewrite-target") && !regexp.MustCompile(`\$\d+`).MatchString(val) {
130131
return true
131132
}
132133
}

0 commit comments

Comments
 (0)