diff options
author | Ethan Koenig <ethantkoenig@gmail.com> | 2017-12-06 17:09:02 -0800 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-12-07 09:09:02 +0800 |
commit | 54907dfbd198628a2da18b8e1f350dd4e4f54514 (patch) | |
tree | 467826428d89cbf08ea038fb103e9403c245d14e | |
parent | 469ab99e9a4e31c1e95ab37f363c26b62b782542 (diff) | |
download | gitea-54907dfbd198628a2da18b8e1f350dd4e4f54514.tar.gz gitea-54907dfbd198628a2da18b8e1f350dd4e4f54514.zip |
Fix legacy URL redirects (#3100)
-rw-r--r-- | integrations/links_test.go | 6 | ||||
-rw-r--r-- | modules/context/repo.go | 6 |
2 files changed, 9 insertions, 3 deletions
diff --git a/integrations/links_test.go b/integrations/links_test.go index e1213a2edc..bc87ca707a 100644 --- a/integrations/links_test.go +++ b/integrations/links_test.go @@ -46,8 +46,10 @@ func TestRedirectsNoLogin(t *testing.T) { prepareTestEnv(t) var redirects = map[string]string{ - "/user2/repo1/commits/master": "/user2/repo1/commits/branch/master", - "/user2/repo1/src/master": "/user2/repo1/src/branch/master", + "/user2/repo1/commits/master": "/user2/repo1/commits/branch/master", + "/user2/repo1/src/master": "/user2/repo1/src/branch/master", + "/user2/repo1/src/master/file.txt": "/user2/repo1/src/branch/master/file.txt", + "/user2/repo1/src/master/directory/file.txt": "/user2/repo1/src/branch/master/directory/file.txt", } for link, redirectLink := range redirects { req := NewRequest(t, "GET", link) diff --git a/modules/context/repo.go b/modules/context/repo.go index 66250a0f3e..7651d43fad 100644 --- a/modules/context/repo.go +++ b/modules/context/repo.go @@ -618,7 +618,11 @@ func RepoRefByType(refType RepoRefType) macaron.Handler { if refType == RepoRefLegacy { // redirect from old URL scheme to new URL scheme - ctx.Redirect(path.Join(setting.AppSubURL, strings.TrimSuffix(ctx.Req.URL.String(), ctx.Params("*")), ctx.Repo.BranchNameSubURL())) + ctx.Redirect(path.Join( + setting.AppSubURL, + strings.TrimSuffix(ctx.Req.URL.String(), ctx.Params("*")), + ctx.Repo.BranchNameSubURL(), + ctx.Repo.TreePath)) return } } |