all repos — homestead @ 770f198ef07726612a824112b69b7eee058e60fa

Code for my website

avoid redirect chains (http -> https, host1 -> host2)

Alan Pearce
commit

770f198ef07726612a824112b69b7eee058e60fa

parent

4999d3f3f11947994f81f128714f4e2096fdd252

1 file changed, 2 insertions(+), 2 deletions(-)

changed files
M internal/website/mux.gointernal/website/mux.go
@@ -15,7 +15,7 @@ "github.com/kevinpollet/nego"
"github.com/pkg/errors" ) -func canonicalisePath(path string) (cPath string, differs bool) { +func CanonicalisePath(path string) (cPath string, differs bool) { cPath = path if strings.HasSuffix(path, "/index.html") { cPath, differs = strings.CutSuffix(path, "index.html")
@@ -72,7 +72,7 @@ }
templates.Setup() mux.Handle("/", wrapHandler(cfg, func(w http.ResponseWriter, r *http.Request) *ihttp.Error { - urlPath, shouldRedirect := canonicalisePath(r.URL.Path) + urlPath, shouldRedirect := CanonicalisePath(r.URL.Path) if shouldRedirect { http.Redirect(w, r, urlPath, 302)