mirror of
https://github.com/caddyserver/caddy.git
synced 2026-08-04 14:58:47 +00:00
rewrite: fix wrong index check in trimPathPrefix (#7812)
This commit is contained in:
parent
25b3eab6db
commit
52dc6709fb
2 changed files with 7 additions and 1 deletions
|
|
@ -432,7 +432,7 @@ func trimPathPrefix(escapedPath, prefix string) string {
|
|||
}
|
||||
|
||||
// if we iterated through the entire prefix, we found it, so trim it
|
||||
if iPath >= len(prefix) {
|
||||
if iPrefix >= len(prefix) {
|
||||
return escapedPath[iPath:]
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -267,6 +267,12 @@ func TestRewrite(t *testing.T) {
|
|||
input: newRequest(t, "GET", "/foo/prefix/bar"),
|
||||
expect: newRequest(t, "GET", "/foo/prefix/bar"),
|
||||
},
|
||||
{
|
||||
// shorter (percent-encoded) path that is not the prefix must be left alone
|
||||
rule: Rewrite{StripPathPrefix: "/aaaaaa"},
|
||||
input: newRequest(t, "GET", "/%61%61"),
|
||||
expect: newRequest(t, "GET", "/%61%61"),
|
||||
},
|
||||
{
|
||||
rule: Rewrite{StripPathPrefix: "//prefix"},
|
||||
// scheme and host needed for URL parser to succeed in setting up test
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue