aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslene <vslene@gmail.com>2014-03-20 09:16:48 +0800
committerslene <vslene@gmail.com>2014-03-20 09:16:48 +0800
commit0e7a2d9d3c59a67e9681d8e6e0d813c191777e2c (patch)
treecd48e5f4aeb522a267850c53489367bb3e465c84
parent67f92c9d47f6e89a9c332f9e938815eac86d0295 (diff)
downloadgitea-0e7a2d9d3c59a67e9681d8e6e0d813c191777e2c.tar.gz
gitea-0e7a2d9d3c59a67e9681d8e6e0d813c191777e2c.zip
directory redirect
-rw-r--r--routers/repo/single.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/routers/repo/single.go b/routers/repo/single.go
index 1c4de34a59..3ab3463028 100644
--- a/routers/repo/single.go
+++ b/routers/repo/single.go
@@ -53,6 +53,12 @@ func Single(ctx *middleware.Context, params martini.Params) {
// Get tree path
treename := params["_1"]
+ if len(treename) > 0 && treename[len(treename)-1] == '/' {
+ ctx.Redirect("/"+ctx.Repo.Owner.LowerName+"/"+
+ ctx.Repo.Repository.Name+"/tree/"+params["branchname"]+"/"+treename[:len(treename)-1], 302)
+ return
+ }
+
// Branches.
brs, err := models.GetBranches(params["username"], params["reponame"])
if err != nil {
@@ -125,7 +131,7 @@ func Single(ctx *middleware.Context, params martini.Params) {
} else {
// current repo branch link
urlPrefix := "http://" + base.Domain + "/" + ctx.Repo.Owner.LowerName + "/" +
- ctx.Repo.Repository.Name + "/blob/" + params["branchname"]
+ ctx.Repo.Repository.Name + "/tree/" + params["branchname"]
ctx.Data["ReadmeContent"] = string(base.RenderMarkdown(blob.Contents(), urlPrefix))
}