Ignore repo and branch in URL

This commit is contained in:
video-prize-ranch 2023-03-28 18:00:22 -04:00
parent a3f60cea18
commit fa769b728e
No known key found for this signature in database
2 changed files with 4 additions and 1 deletions

View file

@ -67,6 +67,9 @@ func (o *Options) matchRedirects(ctx *context.Context, giteaClient *gitea.Client
if len(redirects) > 0 {
for _, redirect := range redirects {
reqUrl := ctx.Req.RequestURI
// remove repo and branch from request url
reqUrl = strings.TrimPrefix(reqUrl, "/" + o.TargetRepo)
reqUrl = strings.TrimPrefix(reqUrl, "/@" + o.TargetBranch)
// check if from url matches request url
if strings.TrimSuffix(redirect.From, "/") == strings.TrimSuffix(reqUrl, "/") {