summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/rewrite/rewrite_test.go
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2022-05-09 11:09:42 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2022-05-09 11:09:42 -0600
commit693e9b5283e675b56084ecc83d73176cab0ee27c (patch)
tree3bd27fce798973c3cbc39f9e4ef18bd5e08df845 /modules/caddyhttp/rewrite/rewrite_test.go
parentb687d7b9670890efd8dc065fb7a025cd0c3a1445 (diff)
rewrite: Handle fragment before query (fix #4775)
Diffstat (limited to 'modules/caddyhttp/rewrite/rewrite_test.go')
-rw-r--r--modules/caddyhttp/rewrite/rewrite_test.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/modules/caddyhttp/rewrite/rewrite_test.go b/modules/caddyhttp/rewrite/rewrite_test.go
index 3e2e13d..84dce95 100644
--- a/modules/caddyhttp/rewrite/rewrite_test.go
+++ b/modules/caddyhttp/rewrite/rewrite_test.go
@@ -204,6 +204,16 @@ func TestRewrite(t *testing.T) {
input: newRequest(t, "GET", "/%C2%B7%E2%88%B5.png?a=b"),
expect: newRequest(t, "GET", "/i/%C2%B7%E2%88%B5.png?a=b"),
},
+ {
+ rule: Rewrite{URI: "/bar#?"},
+ input: newRequest(t, "GET", "/foo#fragFirst?c=d"), // not a valid query string (is part of fragment)
+ expect: newRequest(t, "GET", "/bar#?"), // I think this is right? but who knows; std lib drops fragment when parsing
+ },
+ {
+ rule: Rewrite{URI: "/bar"},
+ input: newRequest(t, "GET", "/foo#fragFirst?c=d"),
+ expect: newRequest(t, "GET", "/bar#fragFirst?c=d"),
+ },
{
rule: Rewrite{StripPathPrefix: "/prefix"},
@@ -271,10 +281,11 @@ func TestRewrite(t *testing.T) {
} {
// copy the original input just enough so that we can
// compare it after the rewrite to see if it changed
+ urlCopy := *tc.input.URL
originalInput := &http.Request{
Method: tc.input.Method,
RequestURI: tc.input.RequestURI,
- URL: &*tc.input.URL,
+ URL: &urlCopy,
}
// populate the replacer just enough for our tests