mirror of
https://github.com/caddyserver/caddy.git
synced 2025-05-30 15:58:10 +08:00
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.
This commit is contained in:
@ -63,6 +63,16 @@ func TestRewrite(t *testing.T) {
|
||||
input: newRequest(t, "GET", "/bar"),
|
||||
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", "/"),
|
||||
|
Reference in New Issue
Block a user