diff options
author | Matthew Holt <mholt@users.noreply.github.com> | 2020-01-15 11:44:21 -0700 |
---|---|---|
committer | Matthew Holt <mholt@users.noreply.github.com> | 2020-01-15 11:44:21 -0700 |
commit | 07ad4655db5d37635edf36fa91d997d166d306b0 (patch) | |
tree | 650c80de9c3eab174c692142f58246c7a429003e /modules/caddyhttp/rewrite/rewrite_test.go | |
parent | 271b5af14894a8cca5fc6aa6f1c17823a1fb5ff3 (diff) |
rewrite: Make URI modifications more transactional (#2891)
Before, modifying the path might have affected how a new query string
was built if the query string relied on the path. Now, we build each
component in isolation and only change the URI on the request later.
Also, prevent trailing & in query string.
Diffstat (limited to 'modules/caddyhttp/rewrite/rewrite_test.go')
-rw-r--r-- | modules/caddyhttp/rewrite/rewrite_test.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/modules/caddyhttp/rewrite/rewrite_test.go b/modules/caddyhttp/rewrite/rewrite_test.go index 3dbc2d6..34a0cdb 100644 --- a/modules/caddyhttp/rewrite/rewrite_test.go +++ b/modules/caddyhttp/rewrite/rewrite_test.go @@ -64,6 +64,16 @@ func TestRewrite(t *testing.T) { expect: newRequest(t, "GET", "/foo/bar"), }, { + rule: Rewrite{URI: "/index.php?p={http.request.uri.path}"}, + input: newRequest(t, "GET", "/foo/bar"), + expect: newRequest(t, "GET", "/index.php?p=%2Ffoo%2Fbar"), + }, + { + rule: Rewrite{URI: "?a=b&{http.request.uri.query}"}, + input: newRequest(t, "GET", "/"), + expect: newRequest(t, "GET", "/?a=b"), + }, + { rule: Rewrite{URI: "/?c=d"}, input: newRequest(t, "GET", "/"), expect: newRequest(t, "GET", "/?c=d"), |