E57C Fix regex rewrite · nginx/kubernetes-ingress@f1bbdc7 · GitHub
[go: up one dir, main page]

Skip to content

Commit f1bbdc7

Browse files
committed
Fix regex rewrite
1 parent 326c929 commit f1bbdc7

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

internal/configs/virtualserver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ func generateRewrites(path string, proxy *conf_v1.ActionProxy, internal bool, or
555555
}
556556

557557
if isRegex {
558-
rewrites = append(rewrites, fmt.Sprintf(`"^%v$" "%v" break`, trimmedPath, proxy.RewritePath))
558+
rewrites = append(rewrites, fmt.Sprintf(`"^%v" "%v" break`, trimmedPath, proxy.RewritePath))
559559
} else if internal {
560560
rewrites = append(rewrites, fmt.Sprintf(`"^%v(.*)$" "%v$1" break`, trimmedPath, proxy.RewritePath))
561561
}

internal/configs/virtualserver_test.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3905,15 +3905,6 @@ func TestGenerateRewrites(t *testing.T) {
39053905
originalPath: "/path",
39063906
expected: []string{`^ $request_uri`, `"^/path(.*)$" "/rewrite$1" break`},
39073907
},
3908-
{
3909-
path: "/_internal_path",
3910-
internal: true,
3911-
proxy: &conf_v1.ActionProxy{
3912-
RewritePath: "/rewrite",
3913-
},
3914-
originalPath: "/path",
3915-
expected: []string{`^ $request_uri`, `"^/path(.*)$" "/rewrite$1" break`},
3916-
},
39173908
{
39183909
path: "~/regex",
39193910
internal: true,
@@ -3929,7 +3920,7 @@ func TestGenerateRewrites(t *testing.T) {
39293920
proxy: &conf_v1.ActionProxy{
39303921
RewritePath: "/rewrite",
39313922
},
3932-
expected: []string{`"^/regex$" "/rewrite" break`},
3923+
expected: []string{`"^/regex" "/rewrite" break`},
39333924
},
39343925
}
39353926

@@ -4166,6 +4157,7 @@ func TestGenerateProxyIgnoreHeaders(t *testing.T) {
41664157
proxy: &conf_v1.ActionProxy{
41674158
ResponseHeaders: nil,
41684159
},
4160+
expected: "",
41694161
},
41704162
{
41714163
proxy: &conf_v1.ActionProxy{

0 commit comments

Comments
 (0)
0