From 70c7065f764231c40f266ff39e412f15124b9cfa Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 9 Dec 2021 19:32:30 +0100 Subject: [PATCH] fix #31 --- server/try.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/try.go b/server/try.go index 7223dfa..6dffa44 100644 --- a/server/try.go +++ b/server/try.go @@ -27,7 +27,10 @@ func tryUpstream(ctx *fasthttp.RequestCtx, if !strings.HasSuffix(strings.SplitN(canonicalDomain, "/", 2)[0], string(mainDomainSuffix)) { canonicalPath := string(ctx.RequestURI()) if targetRepo != "pages" { - canonicalPath = "/" + strings.SplitN(canonicalPath, "/", 3)[2] + path := strings.SplitN(canonicalPath, "/", 3) + if len(path) >= 3 { + canonicalPath = "/" + strings.SplitN(canonicalPath, "/", 3)[2] + } } ctx.Redirect("https://"+canonicalDomain+canonicalPath, fasthttp.StatusTemporaryRedirect) return