Skip to content

Commit 92cb2a8

Browse files
committed
simplify to use ctx.Repo.RepoLink
1 parent 6096ad5 commit 92cb2a8

File tree

2 files changed

+2
-71
lines changed

2 files changed

+2
-71
lines changed

routers/web/repo/view_home.go

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"fmt"
99
"html/template"
1010
"net/http"
11-
"net/url"
1211
"path"
1312
"strings"
1413
"time"
@@ -416,25 +415,6 @@ func Home(ctx *context.Context) {
416415

417416
// HomeRedirect redirects from /tree/* to /src/* in order to maintain a similar URL structure.
418417
func HomeRedirect(ctx *context.Context) {
419-
url := treeRedirectURL(
420-
setting.AppSubURL,
421-
ctx.PathParam("username"),
422-
ctx.PathParam("reponame"),
423-
ctx.PathParam("*"),
424-
)
425-
ctx.Redirect(url)
426-
}
427-
428-
// treeRedirectURL constructs a "src" URL from the given "tree"
429-
// prefixed path params. This is a private function for testing
430-
// purposes.
431-
func treeRedirectURL(prefix, username, reponame, remainder string) string {
432-
return path.Join(
433-
prefix,
434-
"/", // The prefix may be an empty string, so ensure we have a preceding slash
435-
url.PathEscape(username),
436-
url.PathEscape(reponame),
437-
"src",
438-
util.PathEscapeSegments(remainder),
439-
)
418+
remainder := ctx.PathParam("*")
419+
ctx.Redirect(ctx.Repo.RepoLink + "/src/" + util.PathEscapeSegments(remainder))
440420
}

routers/web/repo/view_home_test.go

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)