File tree 1 file changed +20
-0
lines changed
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) {
440
440
ctx .Repo .Owner = owner
441
441
ctx .Data ["Username" ] = ctx .Repo .Owner .Name
442
442
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
+
443
463
// Get repository.
444
464
repo , err := repo_model .GetRepositoryByName (owner .ID , repoName )
445
465
if err != nil {
You can’t perform that action at this time.
0 commit comments