1
0
mirror of https://github.com/golang/go synced 2024-11-21 21:34:40 -07:00

fix reverse proxy issue by returning if the url is blank allowing for direct path reverse proxies instead of appending another slash unnecessarily

This commit is contained in:
Noah Kreiger 2021-12-24 11:39:36 -05:00
parent b357b05b70
commit e7c3bb5f7c
2 changed files with 5 additions and 1 deletions

View File

@ -108,6 +108,9 @@ func singleJoiningSlash(a, b string) string {
case aslash && bslash:
return a + b[1:]
case !aslash && !bslash:
if b == "" {
return a
}
return a + "/" + b
}
return a + b

View File

@ -1497,7 +1497,8 @@ func TestSingleJoinSlash(t *testing.T) {
{"https://www.google.com/", "/favicon.ico", "https://www.google.com/favicon.ico"},
{"https://www.google.com", "/favicon.ico", "https://www.google.com/favicon.ico"},
{"https://www.google.com", "favicon.ico", "https://www.google.com/favicon.ico"},
{"https://www.google.com", "", "https://www.google.com/"},
{"https://www.google.com", "", "https://www.google.com"},
{ "https://www.google.com/favicon.ico", "", "https://www.google.com/favicon.ico"},
{"", "favicon.ico", "/favicon.ico"},
}
for _, tt := range tests {