aboutsummaryrefslogtreecommitdiffstats
path: root/routers/home.go
diff options
context:
space:
mode:
authorBo-Yi Wu <appleboy.tw@gmail.com>2017-02-11 12:00:01 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2017-02-11 12:00:01 +0800
commit3576e1ee739cc03f87e6ce98dbef2f32b517b202 (patch)
tree7eed6fa0e5bd1889807d0754b6767237b7964a5b /routers/home.go
parent55f2059f711268958c2f762934039594ebfa7e56 (diff)
downloadgitea-3576e1ee739cc03f87e6ce98dbef2f32b517b202.tar.gz
gitea-3576e1ee739cc03f87e6ce98dbef2f32b517b202.zip
fix: trim the whitespaces for the search keyword (#893)
Diffstat (limited to 'routers/home.go')
-rw-r--r--routers/home.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/routers/home.go b/routers/home.go
index f5172182d5..6f211f4f62 100644
--- a/routers/home.go
+++ b/routers/home.go
@@ -5,12 +5,12 @@
package routers
import (
+ "bytes"
"fmt"
+ "strings"
"github.com/Unknwon/paginater"
- "bytes"
-
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/context"
@@ -100,7 +100,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
orderBy = "created_unix DESC"
}
- keyword := ctx.Query("q")
+ keyword := strings.Trim(ctx.Query("q"), " ")
if len(keyword) == 0 {
repos, err = opts.Ranger(&models.SearchRepoOptions{
Page: page,
@@ -199,7 +199,7 @@ func RenderUserSearch(ctx *context.Context, opts *UserSearchOptions) {
orderBy = "id DESC"
}
- keyword := ctx.Query("q")
+ keyword := strings.Trim(ctx.Query("q"), " ")
if len(keyword) == 0 {
users, err = opts.Ranger(&models.SearchUserOptions{OrderBy: orderBy,
Page: page,