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:
@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user