Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add request/response modifiers to VS and VSR #1006

Merged
merged 3 commits into from
Jun 25, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix regex rewrite
  • Loading branch information
Raul Marrero committed Jun 24, 2020
commit f1bbdc7e5a362fc19f3949e4f43c758cf828ee3b
2 changes: 1 addition & 1 deletion internal/configs/virtualserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ func generateRewrites(path string, proxy *conf_v1.ActionProxy, internal bool, or
}

if isRegex {
rewrites = append(rewrites, fmt.Sprintf(`"^%v$" "%v" break`, trimmedPath, proxy.RewritePath))
rewrites = append(rewrites, fmt.Sprintf(`"^%v" "%v" break`, trimmedPath, proxy.RewritePath))
} else if internal {
rewrites = append(rewrites, fmt.Sprintf(`"^%v(.*)$" "%v$1" break`, trimmedPath, proxy.RewritePath))
}
Expand Down
12 changes: 2 additions & 10 deletions internal/configs/virtualserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3905,15 +3905,6 @@ func TestGenerateRewrites(t *testing.T) {
originalPath: "/path",
expected: []string{`^ $request_uri`, `"^/path(.*)$" "/rewrite$1" break`},
},
{
path: "/_internal_path",
internal: true,
proxy: &conf_v1.ActionProxy{
RewritePath: "/rewrite",
},
originalPath: "/path",
expected: []string{`^ $request_uri`, `"^/path(.*)$" "/rewrite$1" break`},
},
{
path: "~/regex",
internal: true,
Expand All @@ -3929,7 +3920,7 @@ func TestGenerateRewrites(t *testing.T) {
proxy: &conf_v1.ActionProxy{
RewritePath: "/rewrite",
},
expected: []string{`"^/regex$" "/rewrite" break`},
expected: []string{`"^/regex" "/rewrite" break`},
},
}

Expand Down Expand Up @@ -4166,6 +4157,7 @@ func TestGenerateProxyIgnoreHeaders(t *testing.T) {
proxy: &conf_v1.ActionProxy{
ResponseHeaders: nil,
},
Rulox marked this conversation as resolved.
Show resolved Hide resolved
expected: "",
},
{
proxy: &conf_v1.ActionProxy{
Expand Down