From 51c79f512d0c4972b6acf328035ab504619860b6 Mon Sep 17 00:00:00 2001 From: Moritz Marquardt Date: Sat, 4 Dec 2021 13:54:18 +0100 Subject: [PATCH] Fix github-style non-.html URLs repeating the path twice Issue was reported in https://codeberg.org/Codeberg/Community/issues/547#issuecomment-285075 --- handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handler.go b/handler.go index 4647342..626385d 100644 --- a/handler.go +++ b/handler.go @@ -446,7 +446,7 @@ func upstream(ctx *fasthttp.RequestCtx, targetOwner string, targetRepo string, t } // compatibility fix for GitHub Pages (/example → /example.html) optionsForIndexPages.AppendTrailingSlash = false - optionsForIndexPages.RedirectIfExists = targetPath + ".html" + optionsForIndexPages.RedirectIfExists = string(ctx.Request.URI().Path()) + ".html" if upstream(ctx, targetOwner, targetRepo, targetBranch, targetPath + ".html", &optionsForIndexPages) { _ = fileResponseCache.Set(uri+"?timestamp="+strconv.FormatInt(options.BranchTimestamp.Unix(), 10), fileResponse{ exists: false,