Fix github-style non-.html URLs repeating the path twice

Issue was reported in https://codeberg.org/Codeberg/Community/issues/547#issuecomment-285075
This commit is contained in:
Moritz Marquardt 2021-12-04 13:54:18 +01:00
parent 38938e884d
commit 51c79f512d

View file

@ -446,7 +446,7 @@ func upstream(ctx *fasthttp.RequestCtx, targetOwner string, targetRepo string, t
} }
// compatibility fix for GitHub Pages (/example → /example.html) // compatibility fix for GitHub Pages (/example → /example.html)
optionsForIndexPages.AppendTrailingSlash = false optionsForIndexPages.AppendTrailingSlash = false
optionsForIndexPages.RedirectIfExists = targetPath + ".html" optionsForIndexPages.RedirectIfExists = string(ctx.Request.URI().Path()) + ".html"
if upstream(ctx, targetOwner, targetRepo, targetBranch, targetPath + ".html", &optionsForIndexPages) { if upstream(ctx, targetOwner, targetRepo, targetBranch, targetPath + ".html", &optionsForIndexPages) {
_ = fileResponseCache.Set(uri+"?timestamp="+strconv.FormatInt(options.BranchTimestamp.Unix(), 10), fileResponse{ _ = fileResponseCache.Set(uri+"?timestamp="+strconv.FormatInt(options.BranchTimestamp.Unix(), 10), fileResponse{
exists: false, exists: false,