Skip to content

Commit

Permalink
Use TrimPrefix to strip listen path (#2316)
Browse files Browse the repository at this point in the history
Fixes #2313 
Same as #2211 Missed this case

`strings.Replace()` method was used to strip the `listen_path`.
So when URL rewrite plugin was used to call an endpoint that contained `listen_path` anywhere in it's path, it was getting removed.

To fix this I replaced `strings.Replace()` with `strings.TrimPrefix()`
  • Loading branch information
komalsukhani authored and buger committed May 29, 2019
1 parent 5290f8f commit 3af0129
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gateway/handler_success.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ func (s *SuccessHandler) ServeHTTPWithCache(w http.ResponseWriter, r *http.Reque

// Make sure we get the correct target URL
if s.Spec.Proxy.StripListenPath {
r.URL.Path = strings.Replace(r.URL.Path, s.Spec.Proxy.ListenPath, "", 1)
r.URL.RawPath = strings.Replace(r.URL.RawPath, s.Spec.Proxy.ListenPath, "", 1)
r.URL.Path = strings.TrimPrefix(r.URL.Path, s.Spec.Proxy.ListenPath)
r.URL.RawPath = strings.TrimPrefix(r.URL.RawPath, s.Spec.Proxy.ListenPath)
}

t1 := time.Now()
Expand Down

0 comments on commit 3af0129

Please sign in to comment.