~sircmpwn/kineto

6d23d00a6fdb52df29218265a321d44c950cf513 — Adnan Maolood 3 years ago 1975525
Fix relative redirects

Setting next.Host before setting next.Path breaks relative redirects on
external sites, where next.Host != r.URL.Host.
1 files changed, 1 insertions(+), 1 deletions(-)

M main.go
M main.go => main.go +1 -1
@@ 426,10 426,10 @@ func proxyGemini(req gemini.Request, external bool, root *url.URL,
			w.Write([]byte(fmt.Sprintf("This page is redirecting you to %s", next.String())))
			return
		}
		next.Host = r.URL.Host
		if external {
			next.Path = fmt.Sprintf("/x/%s/%s", next.Host, next.Path)
		}
		next.Host = r.URL.Host
		next.Scheme = r.URL.Scheme
		w.Header().Add("Location", next.String())
		w.WriteHeader(http.StatusFound)