File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -440,6 +440,26 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
440440 ctx .Repo .Owner = owner
441441 ctx .Data ["Username" ] = ctx .Repo .Owner .Name
442442
443+ // redirect link to wiki
444+ if strings .HasSuffix (repoName , ".wiki" ) {
445+ // ctx.Req.URL.Path does not have the preceding appSubURL - any redirect must have this added
446+ // Now we happen to know that all of our paths are: /:username/:reponame/whatever_else
447+ originalRepoName := ctx .Params (":reponame" )
448+ redirectRepoName := strings .TrimSuffix (repoName , ".wiki" )
449+ redirectRepoName += originalRepoName [len (redirectRepoName )+ 5 :]
450+ redirectPath := strings .Replace (
451+ ctx .Req .URL .EscapedPath (),
452+ url .PathEscape (userName )+ "/" + url .PathEscape (originalRepoName ),
453+ url .PathEscape (userName )+ "/" + url .PathEscape (redirectRepoName )+ "/wiki" ,
454+ 1 ,
455+ )
456+ if ctx .Req .URL .RawQuery != "" {
457+ redirectPath += "?" + ctx .Req .URL .RawQuery
458+ }
459+ ctx .Redirect (path .Join (setting .AppSubURL , redirectPath ))
460+ return
461+ }
462+
443463 // Get repository.
444464 repo , err := repo_model .GetRepositoryByName (owner .ID , repoName )
445465 if err != nil {
You can’t perform that action at this time.
0 commit comments