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 @@ -441,6 +441,26 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
441
441
ctx .Repo .Owner = owner
442
442
ctx .Data ["Username" ] = ctx .Repo .Owner .Name
443
443
444
+ // redirect link to wiki
445
+ if strings .HasSuffix (repoName , ".wiki" ) {
446
+ // ctx.Req.URL.Path does not have the preceding appSubURL - any redirect must have this added
447
+ // Now we happen to know that all of our paths are: /:username/:reponame/whatever_else
448
+ originalRepoName := ctx .Params (":reponame" )
449
+ redirectRepoName := strings .TrimSuffix (repoName , ".wiki" )
450
+ redirectRepoName += originalRepoName [len (redirectRepoName )+ 5 :]
451
+ redirectPath := strings .Replace (
452
+ ctx .Req .URL .EscapedPath (),
453
+ url .PathEscape (userName )+ "/" + url .PathEscape (originalRepoName ),
454
+ url .PathEscape (userName )+ "/" + url .PathEscape (redirectRepoName )+ "/wiki" ,
455
+ 1 ,
456
+ )
457
+ if ctx .Req .URL .RawQuery != "" {
458
+ redirectPath += "?" + ctx .Req .URL .RawQuery
459
+ }
460
+ ctx .Redirect (path .Join (setting .AppSubURL , redirectPath ))
461
+ return
462
+ }
463
+
444
464
// Get repository.
445
465
repo , err := repo_model .GetRepositoryByName (owner .ID , repoName )
446
466
if err != nil {
You can’t perform that action at this time.
0 commit comments