Skip to content

Commit 4d5b265

Browse files
committed
handle link
Signed-off-by: a1012112796 <[email protected]>
1 parent bbf6a27 commit 4d5b265

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

modules/context/repo.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,20 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
442442

443443
// redirect link to wiki
444444
if strings.HasSuffix(repoName, ".wiki") {
445-
ctx.Redirect(strings.Replace(ctx.Req.RequestURI, ".wiki", "/wiki", 1))
445+
parts := strings.Split(ctx.Req.RequestURI, "/")
446+
for i := len(parts) - 1; i >= 0; i-- {
447+
if parts[i] == repoName {
448+
parts[i] = strings.Replace(parts[i], ".wiki", "/wiki", 1)
449+
break
450+
}
451+
}
452+
453+
redirectLink := ""
454+
for _, part := range parts {
455+
redirectLink += part + "/"
456+
}
457+
458+
ctx.Redirect(redirectLink)
446459
return
447460
}
448461

0 commit comments

Comments
 (0)