|
@ -199,6 +199,11 @@ func TestRewrite(t *testing.T) { |
|
|
input: newRequest(t, "GET", "/prefix/foo/bar"), |
|
|
input: newRequest(t, "GET", "/prefix/foo/bar"), |
|
|
expect: newRequest(t, "GET", "/foo/bar"), |
|
|
expect: newRequest(t, "GET", "/foo/bar"), |
|
|
}, |
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
rule: Rewrite{StripPathPrefix: "/prefix"}, |
|
|
|
|
|
input: newRequest(t, "GET", "/prefix/foo%2Fbar"), |
|
|
|
|
|
expect: newRequest(t, "GET", "/foo%2Fbar"), |
|
|
|
|
|
}, |
|
|
{ |
|
|
{ |
|
|
rule: Rewrite{StripPathPrefix: "/prefix"}, |
|
|
rule: Rewrite{StripPathPrefix: "/prefix"}, |
|
|
input: newRequest(t, "GET", "/foo/prefix/bar"), |
|
|
input: newRequest(t, "GET", "/foo/prefix/bar"), |
|
@ -215,6 +220,11 @@ func TestRewrite(t *testing.T) { |
|
|
input: newRequest(t, "GET", "/foo/bar/suffix"), |
|
|
input: newRequest(t, "GET", "/foo/bar/suffix"), |
|
|
expect: newRequest(t, "GET", "/foo/bar/"), |
|
|
expect: newRequest(t, "GET", "/foo/bar/"), |
|
|
}, |
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
rule: Rewrite{StripPathSuffix: "suffix"}, |
|
|
|
|
|
input: newRequest(t, "GET", "/foo%2Fbar/suffix"), |
|
|
|
|
|
expect: newRequest(t, "GET", "/foo%2Fbar/"), |
|
|
|
|
|
}, |
|
|
{ |
|
|
{ |
|
|
rule: Rewrite{StripPathSuffix: "/suffix"}, |
|
|
rule: Rewrite{StripPathSuffix: "/suffix"}, |
|
|
input: newRequest(t, "GET", "/foo/suffix/bar"), |
|
|
input: newRequest(t, "GET", "/foo/suffix/bar"), |
|
@ -231,6 +241,11 @@ func TestRewrite(t *testing.T) { |
|
|
input: newRequest(t, "GET", "/foo/findme/bar"), |
|
|
input: newRequest(t, "GET", "/foo/findme/bar"), |
|
|
expect: newRequest(t, "GET", "/foo/replaced/bar"), |
|
|
expect: newRequest(t, "GET", "/foo/replaced/bar"), |
|
|
}, |
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
rule: Rewrite{URISubstring: []replacer{{Find: "findme", Replace: "replaced"}}}, |
|
|
|
|
|
input: newRequest(t, "GET", "/foo/findme%2Fbar"), |
|
|
|
|
|
expect: newRequest(t, "GET", "/foo/replaced%2Fbar"), |
|
|
|
|
|
}, |
|
|
} { |
|
|
} { |
|
|
// copy the original input just enough so that we can
|
|
|
// copy the original input just enough so that we can
|
|
|
// compare it after the rewrite to see if it changed
|
|
|
// compare it after the rewrite to see if it changed
|
|
|