Skip to content

redirect .wiki/* ui link to /wiki #18831

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Mar 23, 2022
6 changes: 6 additions & 0 deletions modules/context/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,12 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
ctx.Repo.Owner = owner
ctx.Data["Username"] = ctx.Repo.Owner.Name

// redirect link to wiki
if strings.HasSuffix(repoName, ".wiki") {
ctx.Redirect(strings.Replace(ctx.Req.RequestURI, ".wiki", "/wiki", 1))
Copy link
Member

@silverwind silverwind Feb 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would break on https://foo.wiki/user/repo.wiki?query=foo.wiki. Would at least include the repo name in the replacement, or properly parse the URL apart and join it again after replacement on the path.

return
}

// Get repository.
repo, err := repo_model.GetRepositoryByName(owner.ID, repoName)
if err != nil {
Expand Down