Compare commits

..

1 Commits

Author SHA1 Message Date
Daniel Erat
fe8cdf892c
Avoid extra slashes in redirects with :splat
Remove leading slashes from captured portions of paths when
redirecting using splats. This makes a directive like
"/articles/*  /posts/:splat  302" behave as described in
FEATURES.md, i.e. "/articles/foo" now redirects to
"/posts/foo" rather than to "/posts//foo". Fixes #269.

This also changes the behavior of a redirect like
"/articles/*  /posts:splat  302". "/articles/foo" will now
redirect to "/postsfoo" rather than to "/posts/foo".

This change also fixes an issue where paths like
"/articles123" would be incorrectly matched by the above
patterns.
2024-04-18 17:34:17 -04:00

View File

@ -1,7 +1,6 @@
package handler
import (
"fmt"
"net/http"
"strings"
@ -42,7 +41,7 @@ func tryUpstream(ctx *context.Context, giteaClient *gitea.Client,
// Try to request the file from the Gitea API
if !options.Upstream(ctx, giteaClient, redirectsCache) {
html.ReturnErrorPage(ctx, fmt.Sprintf("Forge returned %d %s", ctx.StatusCode, http.StatusText(ctx.StatusCode)), ctx.StatusCode)
html.ReturnErrorPage(ctx, "forge client failed", ctx.StatusCode)
}
}