mirror of
https://github.com/go-gitea/gitea
synced 2024-12-23 09:37:51 +01:00
Backport #18831 Redirect .wiki/* ui link to /wiki fix #18590 Signed-off-by: a1012112796 <1012112796@qq.com> Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Andrew Thornton <art27@cantab.net> Co-authored-by: a1012112796 <1012112796@qq.com>
This commit is contained in:
parent
9c7d8b3096
commit
b1a0a78a51
@ -440,6 +440,26 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
|
|||||||
ctx.Repo.Owner = owner
|
ctx.Repo.Owner = owner
|
||||||
ctx.Data["Username"] = ctx.Repo.Owner.Name
|
ctx.Data["Username"] = ctx.Repo.Owner.Name
|
||||||
|
|
||||||
|
// redirect link to wiki
|
||||||
|
if strings.HasSuffix(repoName, ".wiki") {
|
||||||
|
// ctx.Req.URL.Path does not have the preceding appSubURL - any redirect must have this added
|
||||||
|
// Now we happen to know that all of our paths are: /:username/:reponame/whatever_else
|
||||||
|
originalRepoName := ctx.Params(":reponame")
|
||||||
|
redirectRepoName := strings.TrimSuffix(repoName, ".wiki")
|
||||||
|
redirectRepoName += originalRepoName[len(redirectRepoName)+5:]
|
||||||
|
redirectPath := strings.Replace(
|
||||||
|
ctx.Req.URL.EscapedPath(),
|
||||||
|
url.PathEscape(userName)+"/"+url.PathEscape(originalRepoName),
|
||||||
|
url.PathEscape(userName)+"/"+url.PathEscape(redirectRepoName)+"/wiki",
|
||||||
|
1,
|
||||||
|
)
|
||||||
|
if ctx.Req.URL.RawQuery != "" {
|
||||||
|
redirectPath += "?" + ctx.Req.URL.RawQuery
|
||||||
|
}
|
||||||
|
ctx.Redirect(path.Join(setting.AppSubURL, redirectPath))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Get repository.
|
// Get repository.
|
||||||
repo, err := repo_model.GetRepositoryByName(owner.ID, repoName)
|
repo, err := repo_model.GetRepositoryByName(owner.ID, repoName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user