add special case for handling go-get queries
1 file changed, 5 insertions(+), 1 deletion(-)
changed files
M internal/website/mux.go → internal/website/mux.go
@@ -46,7 +46,11 @@ } } func (website *Website) ServeHTTP(w http.ResponseWriter, r *http.Request) *ihttp.Error { - urlPath, shouldRedirect := website.reader.CanonicalisePath(r.URL.Path) + urlPath := r.URL.Path + if r.URL.Query().Has("go-get") && r.URL.Query().Get("go-get") == "1" { + urlPath = "/go" + r.URL.Path + } + urlPath, shouldRedirect := website.reader.CanonicalisePath(urlPath) if shouldRedirect { website.counter.Count(r, "302") http.Redirect(w, r, urlPath, http.StatusFound)