1
0
mirror of https://github.com/labstack/echo.git synced 2025-07-13 01:30:31 +02:00

using url.EscapedPath instead of custom GetPath, rewritePath func added to middleware - used by proxy and rewrite

This commit is contained in:
Arun Gopalpuri
2020-08-28 12:47:02 -07:00
parent cb84205219
commit 1a6ec73e57
6 changed files with 63 additions and 28 deletions

View File

@ -227,9 +227,12 @@ func ProxyWithConfig(config ProxyConfig) echo.MiddlewareFunc {
// Rewrite
for k, v := range config.rewriteRegex {
replacer := captureTokens(k, echo.GetPath(req))
//use req.URL.Path here or else we will have double escaping
replacer := captureTokens(k, req.URL.Path)
if replacer != nil {
req.URL.Path = replacer.Replace(v)
if err := rewritePath(replacer, v, req); err != nil {
return echo.NewHTTPError(http.StatusBadRequest, "invalid url")
}
}
}