From 67a190f68ae2d351b24a2f9518ba31d01898f7cf Mon Sep 17 00:00:00 2001
From: Moritz Marquardt <git@momar.de>
Date: Sun, 5 Dec 2021 22:12:48 +0100
Subject: [PATCH] Hotfix for #27: avoid slash before .html in GitHub
 compatibility redirects

---
 handler.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/handler.go b/handler.go
index 626385d..d5b0448 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 = string(ctx.Request.URI().Path()) + ".html"
+			optionsForIndexPages.RedirectIfExists = strings.TrimSuffix(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,