diff options
Diffstat (limited to 'routers/api')
-rw-r--r-- | routers/api/v1/notify/repo.go | 2 | ||||
-rw-r--r-- | routers/api/v1/notify/user.go | 3 | ||||
-rw-r--r-- | routers/api/v1/org/team.go | 3 | ||||
-rw-r--r-- | routers/api/v1/repo/issue.go | 8 | ||||
-rw-r--r-- | routers/api/v1/repo/issue_tracked_time.go | 5 | ||||
-rw-r--r-- | routers/api/v1/repo/repo.go | 2 | ||||
-rw-r--r-- | routers/api/v1/user/user.go | 3 |
7 files changed, 11 insertions, 15 deletions
diff --git a/routers/api/v1/notify/repo.go b/routers/api/v1/notify/repo.go index 0bc48aeb16..af4507f896 100644 --- a/routers/api/v1/notify/repo.go +++ b/routers/api/v1/notify/repo.go @@ -171,7 +171,7 @@ func ReadRepoNotifications(ctx *context.APIContext) { // "$ref": "#/responses/empty" lastRead := int64(0) - qLastRead := strings.Trim(ctx.FormString("last_read_at"), " ") + qLastRead := ctx.FormTrim("last_read_at") if len(qLastRead) > 0 { tmpLastRead, err := time.Parse(time.RFC3339, qLastRead) if err != nil { diff --git a/routers/api/v1/notify/user.go b/routers/api/v1/notify/user.go index c4b126c567..c2178b4dee 100644 --- a/routers/api/v1/notify/user.go +++ b/routers/api/v1/notify/user.go @@ -6,7 +6,6 @@ package notify import ( "net/http" - "strings" "time" "code.gitea.io/gitea/models" @@ -122,7 +121,7 @@ func ReadNotifications(ctx *context.APIContext) { // "$ref": "#/responses/empty" lastRead := int64(0) - qLastRead := strings.Trim(ctx.FormString("last_read_at"), " ") + qLastRead := ctx.FormTrim("last_read_at") if len(qLastRead) > 0 { tmpLastRead, err := time.Parse(time.RFC3339, qLastRead) if err != nil { diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go index 7802bede1b..7998bb249f 100644 --- a/routers/api/v1/org/team.go +++ b/routers/api/v1/org/team.go @@ -8,7 +8,6 @@ package org import ( "fmt" "net/http" - "strings" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" @@ -658,7 +657,7 @@ func SearchTeam(ctx *context.APIContext) { opts := &models.SearchTeamOptions{ UserID: ctx.User.ID, - Keyword: strings.TrimSpace(ctx.FormString("q")), + Keyword: ctx.FormTrim("q"), OrgID: ctx.Org.Organization.ID, IncludeDesc: ctx.FormString("include_desc") == "" || ctx.FormBool("include_desc"), ListOptions: listOptions, diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index 6add20cb09..7395d4fdd4 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -140,7 +140,7 @@ func SearchIssues(ctx *context.APIContext) { var issues []*models.Issue var filteredCount int64 - keyword := strings.Trim(ctx.FormString("q"), " ") + keyword := ctx.FormTrim("q") if strings.IndexByte(keyword, 0) >= 0 { keyword = "" } @@ -162,13 +162,13 @@ func SearchIssues(ctx *context.APIContext) { isPull = util.OptionalBoolNone } - labels := strings.TrimSpace(ctx.FormString("labels")) + labels := ctx.FormTrim("labels") var includedLabelNames []string if len(labels) > 0 { includedLabelNames = strings.Split(labels, ",") } - milestones := strings.TrimSpace(ctx.FormString("milestones")) + milestones := ctx.FormTrim("milestones") var includedMilestones []string if len(milestones) > 0 { includedMilestones = strings.Split(milestones, ",") @@ -331,7 +331,7 @@ func ListIssues(ctx *context.APIContext) { var issues []*models.Issue var filteredCount int64 - keyword := strings.Trim(ctx.FormString("q"), " ") + keyword := ctx.FormTrim("q") if strings.IndexByte(keyword, 0) >= 0 { keyword = "" } diff --git a/routers/api/v1/repo/issue_tracked_time.go b/routers/api/v1/repo/issue_tracked_time.go index e2935fd13d..b27b746eb2 100644 --- a/routers/api/v1/repo/issue_tracked_time.go +++ b/routers/api/v1/repo/issue_tracked_time.go @@ -7,7 +7,6 @@ package repo import ( "fmt" "net/http" - "strings" "time" "code.gitea.io/gitea/models" @@ -90,7 +89,7 @@ func ListTrackedTimes(ctx *context.APIContext) { IssueID: issue.ID, } - qUser := strings.Trim(ctx.FormString("user"), " ") + qUser := ctx.FormTrim("user") if qUser != "" { user, err := models.GetUserByName(qUser) if models.IsErrUserNotExist(err) { @@ -500,7 +499,7 @@ func ListTrackedTimesByRepository(ctx *context.APIContext) { } // Filters - qUser := strings.Trim(ctx.FormString("user"), " ") + qUser := ctx.FormTrim("user") if qUser != "" { user, err := models.GetUserByName(qUser) if models.IsErrUserNotExist(err) { diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index fb1472226f..d222c9b080 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -135,7 +135,7 @@ func Search(ctx *context.APIContext) { opts := &models.SearchRepoOptions{ ListOptions: utils.GetListOptions(ctx), Actor: ctx.User, - Keyword: strings.Trim(ctx.FormString("q"), " "), + Keyword: ctx.FormTrim("q"), OwnerID: ctx.FormInt64("uid"), PriorityOwnerID: ctx.FormInt64("priority_owner_id"), TeamID: ctx.FormInt64("team_id"), diff --git a/routers/api/v1/user/user.go b/routers/api/v1/user/user.go index db950bd1ee..e00c8d476d 100644 --- a/routers/api/v1/user/user.go +++ b/routers/api/v1/user/user.go @@ -8,7 +8,6 @@ package user import ( "fmt" "net/http" - "strings" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" @@ -58,7 +57,7 @@ func Search(ctx *context.APIContext) { opts := &models.SearchUserOptions{ Actor: ctx.User, - Keyword: strings.Trim(ctx.FormString("q"), " "), + Keyword: ctx.FormTrim("q"), UID: ctx.FormInt64("uid"), Type: models.UserTypeIndividual, ListOptions: listOptions, |