diff options
author | Bo-Yi Wu <appleboy.tw@gmail.com> | 2017-02-11 12:00:01 +0800 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-02-11 12:00:01 +0800 |
commit | 3576e1ee739cc03f87e6ce98dbef2f32b517b202 (patch) | |
tree | 7eed6fa0e5bd1889807d0754b6767237b7964a5b /routers/api | |
parent | 55f2059f711268958c2f762934039594ebfa7e56 (diff) | |
download | gitea-3576e1ee739cc03f87e6ce98dbef2f32b517b202.tar.gz gitea-3576e1ee739cc03f87e6ce98dbef2f32b517b202.zip |
fix: trim the whitespaces for the search keyword (#893)
Diffstat (limited to 'routers/api')
-rw-r--r-- | routers/api/v1/repo/repo.go | 4 | ||||
-rw-r--r-- | routers/api/v1/user/user.go | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 02c017243e..cbcc10a4d4 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -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")), } diff --git a/routers/api/v1/user/user.go b/routers/api/v1/user/user.go index 20ed180ef7..de99fade46 100644 --- a/routers/api/v1/user/user.go +++ b/routers/api/v1/user/user.go @@ -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(), } |