Closed far-blue closed 3 years ago
@far-blue You are correct. The path stripping is currently done AFTER the replacement of the $path
pseudo variable in the code. I added a new test case and have a patch I'll push shortly.
I also added a new test case for this issue. The fix passes the new test and all existing tests.
Let me know if this resolves your issue.
Great, thanks for this. I don't have experience with building go apps but your unit tests capture the behaviour as I'd expect so if they are passing I'm confident the issue will be fixed :)
I'm trying to use strip and redirect together and I'm not getting the behaviour I'd expect.
What I'm trying to do is:
urlprefix-<host>/news strip=/news redirect=301,https://<host>/bulletin/$path
However, the strip isn't working.
Looking at the code here: https://github.com/fabiolb/fabio/blob/231e7f24a13fde2fca2ffd9e8f553c18addac165/route/target.go#L99
It looks like the redirect destination is assembled first, and then the strip prefix is checked. In my case this would first convert
/new/foo
into/bulletin/news/foo
, then attempt to apply the strip - which will fail.I suspect the code should actually be applying the prefix check and strip to the
replaceRawPath
var rather than thet.RedirectURL.Path
var.