mirror of
https://github.com/go-gitea/gitea
synced 2025-07-23 02:38:35 +00:00
Refactor names (#31405)
This PR only does "renaming": * `Route` should be `Router` (and chi router is also called "router") * `Params` should be `PathParam` (to distingush it from URL query param, and to match `FormString`) * Use lower case for private functions to avoid exposing or abusing
This commit is contained in:
@@ -317,7 +317,7 @@ func RepoRefForAPI(next http.Handler) http.Handler {
|
||||
}
|
||||
ctx.Repo.Commit = commit
|
||||
ctx.Repo.CommitID = ctx.Repo.Commit.ID.String()
|
||||
ctx.Repo.TreePath = ctx.Params("*")
|
||||
ctx.Repo.TreePath = ctx.PathParam("*")
|
||||
next.ServeHTTP(w, req)
|
||||
return
|
||||
}
|
||||
@@ -347,7 +347,7 @@ func RepoRefForAPI(next http.Handler) http.Handler {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
ctx.NotFound(fmt.Errorf("not exist: '%s'", ctx.Params("*")))
|
||||
ctx.NotFound(fmt.Errorf("not exist: '%s'", ctx.PathParam("*")))
|
||||
return
|
||||
}
|
||||
|
||||
|
@@ -143,8 +143,8 @@ func (b *Base) RemoteAddr() string {
|
||||
return b.Req.RemoteAddr
|
||||
}
|
||||
|
||||
// Params returns the param in request path, eg: "/{var}" => "/a%2fb", then `var == "a/b"`
|
||||
func (b *Base) Params(name string) string {
|
||||
// PathParam returns the param in request path, eg: "/{var}" => "/a%2fb", then `var == "a/b"`
|
||||
func (b *Base) PathParam(name string) string {
|
||||
s, err := url.PathUnescape(b.PathParamRaw(name))
|
||||
if err != nil && !setting.IsProd {
|
||||
panic("Failed to unescape path param: " + err.Error() + ", there seems to be a double-unescaping bug")
|
||||
@@ -157,14 +157,14 @@ func (b *Base) PathParamRaw(name string) string {
|
||||
return chi.URLParam(b.Req, strings.TrimPrefix(name, ":"))
|
||||
}
|
||||
|
||||
// ParamsInt64 returns the param in request path as int64
|
||||
func (b *Base) ParamsInt64(p string) int64 {
|
||||
v, _ := strconv.ParseInt(b.Params(p), 10, 64)
|
||||
// PathParamInt64 returns the param in request path as int64
|
||||
func (b *Base) PathParamInt64(p string) int64 {
|
||||
v, _ := strconv.ParseInt(b.PathParam(p), 10, 64)
|
||||
return v
|
||||
}
|
||||
|
||||
// SetParams set request path params into routes
|
||||
func (b *Base) SetParams(k, v string) {
|
||||
// SetPathParam set request path params into routes
|
||||
func (b *Base) SetPathParam(k, v string) {
|
||||
chiCtx := chi.RouteContext(b)
|
||||
chiCtx.URLParams.Add(strings.TrimPrefix(k, ":"), url.PathEscape(v))
|
||||
}
|
||||
|
@@ -41,7 +41,7 @@ func (org *Organization) CanReadUnit(ctx *Context, unitType unit.Type) bool {
|
||||
}
|
||||
|
||||
func GetOrganizationByParams(ctx *Context) {
|
||||
orgName := ctx.Params(":org")
|
||||
orgName := ctx.PathParam(":org")
|
||||
|
||||
var err error
|
||||
|
||||
@@ -221,7 +221,7 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
|
||||
ctx.Data["NumTeams"] = len(ctx.Org.Teams)
|
||||
}
|
||||
|
||||
teamName := ctx.Params(":team")
|
||||
teamName := ctx.PathParam(":team")
|
||||
if len(teamName) > 0 {
|
||||
teamExists := false
|
||||
for _, team := range ctx.Org.Teams {
|
||||
|
@@ -68,9 +68,9 @@ func packageAssignment(ctx *packageAssignmentCtx, errCb func(int, string, any))
|
||||
return pkg
|
||||
}
|
||||
|
||||
packageType := ctx.Params("type")
|
||||
name := ctx.Params("name")
|
||||
version := ctx.Params("version")
|
||||
packageType := ctx.PathParam("type")
|
||||
name := ctx.PathParam("name")
|
||||
version := ctx.PathParam("version")
|
||||
if packageType != "" && name != "" && version != "" {
|
||||
pv, err := packages_model.GetVersionByNameAndVersion(ctx, pkg.Owner.ID, packages_model.Type(packageType), name, version)
|
||||
if err != nil {
|
||||
|
@@ -319,8 +319,8 @@ func ComposeGoGetImport(owner, repo string) string {
|
||||
// This is particular a workaround for "go get" command which does not respect
|
||||
// .netrc file.
|
||||
func EarlyResponseForGoGetMeta(ctx *Context) {
|
||||
username := ctx.Params(":username")
|
||||
reponame := strings.TrimSuffix(ctx.Params(":reponame"), ".git")
|
||||
username := ctx.PathParam(":username")
|
||||
reponame := strings.TrimSuffix(ctx.PathParam(":reponame"), ".git")
|
||||
if username == "" || reponame == "" {
|
||||
ctx.PlainText(http.StatusBadRequest, "invalid repository path")
|
||||
return
|
||||
@@ -339,8 +339,8 @@ func EarlyResponseForGoGetMeta(ctx *Context) {
|
||||
|
||||
// RedirectToRepo redirect to a differently-named repository
|
||||
func RedirectToRepo(ctx *Base, redirectRepoID int64) {
|
||||
ownerName := ctx.Params(":username")
|
||||
previousRepoName := ctx.Params(":reponame")
|
||||
ownerName := ctx.PathParam(":username")
|
||||
previousRepoName := ctx.PathParam(":reponame")
|
||||
|
||||
repo, err := repo_model.GetRepositoryByID(ctx, redirectRepoID)
|
||||
if err != nil {
|
||||
@@ -419,8 +419,8 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
|
||||
err error
|
||||
)
|
||||
|
||||
userName := ctx.Params(":username")
|
||||
repoName := ctx.Params(":reponame")
|
||||
userName := ctx.PathParam(":username")
|
||||
repoName := ctx.PathParam(":reponame")
|
||||
repoName = strings.TrimSuffix(repoName, ".git")
|
||||
if setting.Other.EnableFeed {
|
||||
repoName = strings.TrimSuffix(repoName, ".rss")
|
||||
@@ -463,7 +463,7 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
|
||||
if strings.HasSuffix(repoName, ".wiki") {
|
||||
// ctx.Req.URL.Path does not have the preceding appSubURL - any redirect must have this added
|
||||
// Now we happen to know that all of our paths are: /:username/:reponame/whatever_else
|
||||
originalRepoName := ctx.Params(":reponame")
|
||||
originalRepoName := ctx.PathParam(":reponame")
|
||||
redirectRepoName := strings.TrimSuffix(repoName, ".wiki")
|
||||
redirectRepoName += originalRepoName[len(redirectRepoName)+5:]
|
||||
redirectPath := strings.Replace(
|
||||
@@ -801,7 +801,7 @@ func getRefNameFromPath(repo *Repository, path string, isExist func(string) bool
|
||||
}
|
||||
|
||||
func getRefName(ctx *Base, repo *Repository, pathType RepoRefType) string {
|
||||
path := ctx.Params("*")
|
||||
path := ctx.PathParam("*")
|
||||
switch pathType {
|
||||
case RepoRefLegacy, RepoRefAny:
|
||||
if refName := getRefName(ctx, repo, RepoRefBranch); len(refName) > 0 {
|
||||
@@ -917,7 +917,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
|
||||
}
|
||||
|
||||
// Get default branch.
|
||||
if len(ctx.Params("*")) == 0 {
|
||||
if len(ctx.PathParam("*")) == 0 {
|
||||
refName = ctx.Repo.Repository.DefaultBranch
|
||||
if !ctx.Repo.GitRepo.IsBranchExist(refName) {
|
||||
brs, _, err := ctx.Repo.GitRepo.GetBranches(0, 1)
|
||||
@@ -1005,7 +1005,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context
|
||||
|
||||
if refType == RepoRefLegacy {
|
||||
// redirect from old URL scheme to new URL scheme
|
||||
prefix := strings.TrimPrefix(setting.AppSubURL+strings.ToLower(strings.TrimSuffix(ctx.Req.URL.Path, ctx.Params("*"))), strings.ToLower(ctx.Repo.RepoLink))
|
||||
prefix := strings.TrimPrefix(setting.AppSubURL+strings.ToLower(strings.TrimSuffix(ctx.Req.URL.Path, ctx.PathParam("*"))), strings.ToLower(ctx.Repo.RepoLink))
|
||||
redirect := path.Join(
|
||||
ctx.Repo.RepoLink,
|
||||
util.PathEscapeSegments(prefix),
|
||||
|
@@ -86,8 +86,8 @@ func AddUploadContext(ctx *context.Context, uploadType string) {
|
||||
} else if uploadType == "comment" {
|
||||
ctx.Data["UploadUrl"] = ctx.Repo.RepoLink + "/issues/attachments"
|
||||
ctx.Data["UploadRemoveUrl"] = ctx.Repo.RepoLink + "/issues/attachments/remove"
|
||||
if len(ctx.Params(":index")) > 0 {
|
||||
ctx.Data["UploadLinkUrl"] = ctx.Repo.RepoLink + "/issues/" + url.PathEscape(ctx.Params(":index")) + "/attachments"
|
||||
if len(ctx.PathParam(":index")) > 0 {
|
||||
ctx.Data["UploadLinkUrl"] = ctx.Repo.RepoLink + "/issues/" + url.PathEscape(ctx.PathParam(":index")) + "/attachments"
|
||||
} else {
|
||||
ctx.Data["UploadLinkUrl"] = ctx.Repo.RepoLink + "/issues/attachments"
|
||||
}
|
||||
|
@@ -33,7 +33,7 @@ func UserAssignmentWeb() func(ctx *Context) {
|
||||
// UserIDAssignmentAPI returns a middleware to handle context-user assignment for api routes
|
||||
func UserIDAssignmentAPI() func(ctx *APIContext) {
|
||||
return func(ctx *APIContext) {
|
||||
userID := ctx.ParamsInt64(":user-id")
|
||||
userID := ctx.PathParamInt64(":user-id")
|
||||
|
||||
if ctx.IsSigned && ctx.Doer.ID == userID {
|
||||
ctx.ContextUser = ctx.Doer
|
||||
@@ -59,7 +59,7 @@ func UserAssignmentAPI() func(ctx *APIContext) {
|
||||
}
|
||||
|
||||
func userAssignment(ctx *Base, doer *user_model.User, errCb func(int, string, any)) (contextUser *user_model.User) {
|
||||
username := ctx.Params(":username")
|
||||
username := ctx.PathParam(":username")
|
||||
|
||||
if doer != nil && doer.LowerName == strings.ToLower(username) {
|
||||
contextUser = doer
|
||||
|
@@ -136,8 +136,8 @@ func GetListLockHandler(ctx *context.Context) {
|
||||
|
||||
// PostLockHandler create lock
|
||||
func PostLockHandler(ctx *context.Context) {
|
||||
userName := ctx.Params("username")
|
||||
repoName := strings.TrimSuffix(ctx.Params("reponame"), ".git")
|
||||
userName := ctx.PathParam("username")
|
||||
repoName := strings.TrimSuffix(ctx.PathParam("reponame"), ".git")
|
||||
authorization := ctx.Req.Header.Get("Authorization")
|
||||
|
||||
repository, err := repo_model.GetRepositoryByOwnerAndName(ctx, userName, repoName)
|
||||
@@ -208,8 +208,8 @@ func PostLockHandler(ctx *context.Context) {
|
||||
|
||||
// VerifyLockHandler list locks for verification
|
||||
func VerifyLockHandler(ctx *context.Context) {
|
||||
userName := ctx.Params("username")
|
||||
repoName := strings.TrimSuffix(ctx.Params("reponame"), ".git")
|
||||
userName := ctx.PathParam("username")
|
||||
repoName := strings.TrimSuffix(ctx.PathParam("reponame"), ".git")
|
||||
authorization := ctx.Req.Header.Get("Authorization")
|
||||
|
||||
repository, err := repo_model.GetRepositoryByOwnerAndName(ctx, userName, repoName)
|
||||
@@ -279,8 +279,8 @@ func VerifyLockHandler(ctx *context.Context) {
|
||||
|
||||
// UnLockHandler delete locks
|
||||
func UnLockHandler(ctx *context.Context) {
|
||||
userName := ctx.Params("username")
|
||||
repoName := strings.TrimSuffix(ctx.Params("reponame"), ".git")
|
||||
userName := ctx.PathParam("username")
|
||||
repoName := strings.TrimSuffix(ctx.PathParam("reponame"), ".git")
|
||||
authorization := ctx.Req.Header.Get("Authorization")
|
||||
|
||||
repository, err := repo_model.GetRepositoryByOwnerAndName(ctx, userName, repoName)
|
||||
@@ -321,7 +321,7 @@ func UnLockHandler(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
lock, err := git_model.DeleteLFSLockByID(ctx, ctx.ParamsInt64("lid"), repository, ctx.Doer, req.Force)
|
||||
lock, err := git_model.DeleteLFSLockByID(ctx, ctx.PathParamInt64("lid"), repository, ctx.Doer, req.Force)
|
||||
if err != nil {
|
||||
if git_model.IsErrLFSUnauthorizedAction(err) {
|
||||
ctx.Resp.Header().Set("WWW-Authenticate", "Basic realm=gitea-lfs")
|
||||
@@ -330,7 +330,7 @@ func UnLockHandler(ctx *context.Context) {
|
||||
})
|
||||
return
|
||||
}
|
||||
log.Error("Unable to DeleteLFSLockByID[%d] by user %-v with force %t: Error: %v", ctx.ParamsInt64("lid"), ctx.Doer, req.Force, err)
|
||||
log.Error("Unable to DeleteLFSLockByID[%d] by user %-v with force %t: Error: %v", ctx.PathParamInt64("lid"), ctx.Doer, req.Force, err)
|
||||
ctx.JSON(http.StatusInternalServerError, api.LFSLockError{
|
||||
Message: "unable to delete lock : Internal Server Error",
|
||||
})
|
||||
|
@@ -82,7 +82,7 @@ var rangeHeaderRegexp = regexp.MustCompile(`bytes=(\d+)\-(\d*).*`)
|
||||
// DownloadHandler gets the content from the content store
|
||||
func DownloadHandler(ctx *context.Context) {
|
||||
rc := getRequestContext(ctx)
|
||||
p := lfs_module.Pointer{Oid: ctx.Params("oid")}
|
||||
p := lfs_module.Pointer{Oid: ctx.PathParam("oid")}
|
||||
|
||||
meta := getAuthenticatedMeta(ctx, rc, p, false)
|
||||
if meta == nil {
|
||||
@@ -137,7 +137,7 @@ func DownloadHandler(ctx *context.Context) {
|
||||
ctx.Resp.Header().Set("Content-Length", strconv.FormatInt(contentLength, 10))
|
||||
ctx.Resp.Header().Set("Content-Type", "application/octet-stream")
|
||||
|
||||
filename := ctx.Params("filename")
|
||||
filename := ctx.PathParam("filename")
|
||||
if len(filename) > 0 {
|
||||
decodedFilename, err := base64.RawURLEncoding.DecodeString(filename)
|
||||
if err == nil {
|
||||
@@ -272,9 +272,9 @@ func BatchHandler(ctx *context.Context) {
|
||||
func UploadHandler(ctx *context.Context) {
|
||||
rc := getRequestContext(ctx)
|
||||
|
||||
p := lfs_module.Pointer{Oid: ctx.Params("oid")}
|
||||
p := lfs_module.Pointer{Oid: ctx.PathParam("oid")}
|
||||
var err error
|
||||
if p.Size, err = strconv.ParseInt(ctx.Params("size"), 10, 64); err != nil {
|
||||
if p.Size, err = strconv.ParseInt(ctx.PathParam("size"), 10, 64); err != nil {
|
||||
writeStatusMessage(ctx, http.StatusUnprocessableEntity, err.Error())
|
||||
}
|
||||
|
||||
@@ -384,8 +384,8 @@ func decodeJSON(req *http.Request, v any) error {
|
||||
|
||||
func getRequestContext(ctx *context.Context) *requestContext {
|
||||
return &requestContext{
|
||||
User: ctx.Params("username"),
|
||||
Repo: strings.TrimSuffix(ctx.Params("reponame"), ".git"),
|
||||
User: ctx.PathParam("username"),
|
||||
Repo: strings.TrimSuffix(ctx.PathParam("reponame"), ".git"),
|
||||
Authorization: ctx.Req.Header.Get("Authorization"),
|
||||
}
|
||||
}
|
||||
|
@@ -53,7 +53,7 @@ func getExpectedReadmeContentsResponse() *api.ContentsResponse {
|
||||
func TestGetContents(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
ctx.SetPathParam(":id", "1")
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
@@ -81,7 +81,7 @@ func TestGetContents(t *testing.T) {
|
||||
func TestGetContentsOrListForDir(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
ctx.SetPathParam(":id", "1")
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
@@ -116,7 +116,7 @@ func TestGetContentsOrListForDir(t *testing.T) {
|
||||
func TestGetContentsOrListForFile(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
ctx.SetPathParam(":id", "1")
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
@@ -144,7 +144,7 @@ func TestGetContentsOrListForFile(t *testing.T) {
|
||||
func TestGetContentsErrors(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
ctx.SetPathParam(":id", "1")
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
@@ -175,7 +175,7 @@ func TestGetContentsErrors(t *testing.T) {
|
||||
func TestGetContentsOrListErrors(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
ctx.SetPathParam(":id", "1")
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
@@ -206,7 +206,7 @@ func TestGetContentsOrListErrors(t *testing.T) {
|
||||
func TestGetContentsOrListOfEmptyRepos(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := contexttest.MockContext(t, "user30/empty")
|
||||
ctx.SetParams(":id", "52")
|
||||
ctx.SetPathParam(":id", "52")
|
||||
contexttest.LoadRepo(t, ctx, 52)
|
||||
contexttest.LoadUser(t, ctx, 30)
|
||||
contexttest.LoadGitRepo(t, ctx)
|
||||
@@ -231,15 +231,15 @@ func TestGetBlobBySHA(t *testing.T) {
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
|
||||
sha := "65f1bf27bc3bf70f64657658635e66094edbcb4d"
|
||||
ctx.SetParams(":id", "1")
|
||||
ctx.SetParams(":sha", sha)
|
||||
ctx.SetPathParam(":id", "1")
|
||||
ctx.SetPathParam(":sha", sha)
|
||||
|
||||
gitRepo, err := gitrepo.OpenRepository(ctx, ctx.Repo.Repository)
|
||||
if err != nil {
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
gbr, err := GetBlobBySHA(ctx, ctx.Repo.Repository, gitRepo, ctx.Params(":sha"))
|
||||
gbr, err := GetBlobBySHA(ctx, ctx.Repo.Repository, gitRepo, ctx.PathParam(":sha"))
|
||||
expectedGBR := &api.GitBlobResponse{
|
||||
Content: "dHJlZSAyYTJmMWQ0NjcwNzI4YTJlMTAwNDllMzQ1YmQ3YTI3NjQ2OGJlYWI2CmF1dGhvciB1c2VyMSA8YWRkcmVzczFAZXhhbXBsZS5jb20+IDE0ODk5NTY0NzkgLTA0MDAKY29tbWl0dGVyIEV0aGFuIEtvZW5pZyA8ZXRoYW50a29lbmlnQGdtYWlsLmNvbT4gMTQ4OTk1NjQ3OSAtMDQwMAoKSW5pdGlhbCBjb21taXQK",
|
||||
Encoding: "base64",
|
||||
|
@@ -18,7 +18,7 @@ import (
|
||||
func TestGetDiffPreview(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
ctx.SetPathParam(":id", "1")
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
@@ -140,7 +140,7 @@ func TestGetDiffPreview(t *testing.T) {
|
||||
func TestGetDiffPreviewErrors(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
ctx.SetPathParam(":id", "1")
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
|
@@ -99,7 +99,7 @@ func getExpectedFileResponse() *api.FileResponse {
|
||||
func TestGetFileResponseFromCommit(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
ctx.SetPathParam(":id", "1")
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
|
@@ -25,10 +25,10 @@ func TestGetTreeBySHA(t *testing.T) {
|
||||
sha := ctx.Repo.Repository.DefaultBranch
|
||||
page := 1
|
||||
perPage := 10
|
||||
ctx.SetParams(":id", "1")
|
||||
ctx.SetParams(":sha", sha)
|
||||
ctx.SetPathParam(":id", "1")
|
||||
ctx.SetPathParam(":sha", sha)
|
||||
|
||||
tree, err := GetTreeBySHA(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo, ctx.Params(":sha"), page, perPage, true)
|
||||
tree, err := GetTreeBySHA(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo, ctx.PathParam(":sha"), page, perPage, true)
|
||||
assert.NoError(t, err)
|
||||
expectedTree := &api.GitTreeResponse{
|
||||
SHA: "65f1bf27bc3bf70f64657658635e66094edbcb4d",
|
||||
|
@@ -33,7 +33,7 @@ import (
|
||||
// TODO: support subdirectory in the future
|
||||
//
|
||||
// Although this package now has the ability to support subdirectory, but the route package doesn't:
|
||||
// * Double-escaping problem: the URL "/wiki/abc%2Fdef" becomes "/wiki/abc/def" by ctx.Params, which is incorrect
|
||||
// * Double-escaping problem: the URL "/wiki/abc%2Fdef" becomes "/wiki/abc/def" by ctx.PathParam, which is incorrect
|
||||
// * This problem should have been 99% fixed, but it needs more tests.
|
||||
// * The old wiki code's behavior is always using %2F, instead of subdirectory, so there are a lot of legacy "%2F" files in user wikis.
|
||||
|
||||
|
Reference in New Issue
Block a user