Skip to content

Commit

Permalink
Ignore "@" sign at the beginning of user searches (#9780)
Browse files Browse the repository at this point in the history
This trims the "@" symbol from the begging of the search term before executing the query.
  • Loading branch information
zeroimpl authored and crspeller committed Nov 12, 2018
1 parent 7a758ea commit fa0aecc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion store/sqlstore/user_store.go
Expand Up @@ -1166,7 +1166,7 @@ func generateSearchQuery(searchQuery string, terms []string, fields []string, pa
}
}
searchTerms = append(searchTerms, fmt.Sprintf("(%s)", strings.Join(searchFields, " OR ")))
parameters[fmt.Sprintf("Term%d", i)] = fmt.Sprintf("%s%%", term)
parameters[fmt.Sprintf("Term%d", i)] = fmt.Sprintf("%s%%", strings.TrimLeft(term, "@"))
}

searchClause := strings.Join(searchTerms, " AND ")
Expand Down
10 changes: 10 additions & 0 deletions store/storetest/user_store.go
Expand Up @@ -1658,6 +1658,16 @@ func testUserStoreSearch(t *testing.T, ss store.Store) {
},
[]*model.User{u1},
},
{
"leading @ should be ignored",
tid,
"@jimb",
&model.UserSearchOptions{
AllowFullNames: true,
Limit: model.USER_SEARCH_DEFAULT_LIMIT,
},
[]*model.User{u1},
},
}

for _, testCase := range testCases {
Expand Down

0 comments on commit fa0aecc

Please sign in to comment.