1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

fix: trim the whitespaces for the search keyword (#893)

This commit is contained in:
Bo-Yi Wu
2017-02-11 12:00:01 +08:00
committed by Lunny Xiao
parent 55f2059f71
commit 3576e1ee73
7 changed files with 14 additions and 11 deletions

View File

@@ -5,7 +5,7 @@
package repo
import (
"path"
"strings"
api "code.gitea.io/sdk/gitea"
@@ -21,7 +21,7 @@ import (
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#search-repositories
func Search(ctx *context.APIContext) {
opts := &models.SearchRepoOptions{
Keyword: path.Base(ctx.Query("q")),
Keyword: strings.Trim(ctx.Query("q"), " "),
OwnerID: ctx.QueryInt64("uid"),
PageSize: convert.ToCorrectPageSize(ctx.QueryInt("limit")),
}

View File

@@ -5,6 +5,8 @@
package user
import (
"strings"
"github.com/Unknwon/com"
api "code.gitea.io/sdk/gitea"
@@ -16,7 +18,7 @@ import (
// Search search users
func Search(ctx *context.APIContext) {
opts := &models.SearchUserOptions{
Keyword: ctx.Query("q"),
Keyword: strings.Trim(ctx.Query("q"), " "),
Type: models.UserTypeIndividual,
PageSize: com.StrTo(ctx.Query("limit")).MustInt(),
}