~emersion/public-inbox

kimchi: Fix stripping trailing slash when forwarding v2 APPLIED

Krystian Chachuła: 1
 Fix stripping trailing slash when forwarding

 1 files changed, 3 insertions(+), 0 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/public-inbox/patches/54295/mbox | git am -3
Learn more about email & git

[PATCH kimchi v2] Fix stripping trailing slash when forwarding Export this patch

path.Join strips trailing slashes. This leads to redirection loops when
the backend enforces trailing slashes by redirecting. This commit adds
the trailing slashes back.

---
Thanks for the review of v1. I looked up how URL.JoinPath deals with
trailing slashes. It adds them back like this.

 directives.go | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/directives.go b/directives.go
index 94258d3..5ec62a2 100644
--- a/directives.go
+++ b/directives.go
@@ -226,6 +226,9 @@ var backends = map[string]parseBackendFunc{
			req.URL.Host = target.Host
			if strings.HasSuffix(target.Path, "/") {
				p := path.Join("/", req.URL.Path)
				if strings.HasSuffix(req.URL.Path, "/") && !strings.HasSuffix(p, "/") {
					p += "/"
				}
				req.URL.Path = strings.TrimSuffix(target.Path, "/") + p
			} else {
				req.URL.Path = target.Path
-- 
2.45.1
Pushed, thanks!