Allow empty replacement with ReplacePathRegex middleware
This commit is contained in:
parent
3fcf265d80
commit
7f29595c0a
2 changed files with 23 additions and 1 deletions
|
@ -53,7 +53,7 @@ func (rp *replacePathRegex) ServeHTTP(rw http.ResponseWriter, req *http.Request)
|
|||
currentPath = req.URL.EscapedPath()
|
||||
}
|
||||
|
||||
if rp.regexp != nil && len(rp.replacement) > 0 && rp.regexp.MatchString(currentPath) {
|
||||
if rp.regexp != nil && rp.regexp.MatchString(currentPath) {
|
||||
req.Header.Add(replacepath.ReplacedPathHeader, currentPath)
|
||||
req.URL.RawPath = rp.regexp.ReplaceAllString(currentPath, rp.replacement)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue