From 6d23d00a6fdb52df29218265a321d44c950cf513 Mon Sep 17 00:00:00 2001 From: Adnan Maolood Date: Wed, 24 Feb 2021 17:50:31 -0500 Subject: [PATCH] Fix relative redirects Setting next.Host before setting next.Path breaks relative redirects on external sites, where next.Host != r.URL.Host. --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index f13605e..bbfac30 100644 --- a/main.go +++ b/main.go @@ -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)