mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-31 19:38:23 +00:00 
			
		
		
		
	directory redirect
This commit is contained in:
		| @@ -53,6 +53,12 @@ func Single(ctx *middleware.Context, params martini.Params) { | |||||||
| 	// Get tree path | 	// Get tree path | ||||||
| 	treename := params["_1"] | 	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. | 	// Branches. | ||||||
| 	brs, err := models.GetBranches(params["username"], params["reponame"]) | 	brs, err := models.GetBranches(params["username"], params["reponame"]) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| @@ -125,7 +131,7 @@ func Single(ctx *middleware.Context, params martini.Params) { | |||||||
| 		} else { | 		} else { | ||||||
| 			// current repo branch link | 			// current repo branch link | ||||||
| 			urlPrefix := "http://" + base.Domain + "/" + ctx.Repo.Owner.LowerName + "/" + | 			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)) | 			ctx.Data["ReadmeContent"] = string(base.RenderMarkdown(blob.Contents(), urlPrefix)) | ||||||
| 		} | 		} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user