1
0
Fork 0
forked from forgejo/forgejo

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,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,