Skip to content

Commit

Permalink
Only match all things for broad queries, for invalid ones return nothing
Browse files Browse the repository at this point in the history
This resolves #237
  • Loading branch information
ximion committed Jun 16, 2019
1 parent 83b7d34 commit 0d74990
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/as-pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -1553,10 +1553,19 @@ as_pool_search (AsPool *pool, const gchar *search)

/* sanitize user's search term */
terms = as_pool_build_search_terms (pool, search);
result = g_ptr_array_new_with_free_func (g_object_unref);

if (terms == NULL) {
g_debug ("Search term invalid. Matching everything.");
/* the query was invalid */
g_autofree gchar *tmp = g_strdup (search);
g_strstrip (tmp);
if (strlen (tmp) <= 1) {
/* we have a one-letter search query - we cheat here and just return everything */
g_debug ("Search query too broad. Matching everything.");
return as_pool_get_components (pool);
} else {
g_debug ("No valid search terms. Can not find any results.");
return g_ptr_array_new_with_free_func (g_object_unref);
}
} else {
g_autofree gchar *tmp_str = NULL;
tmp_str = g_strjoinv (" ", terms);
Expand Down

0 comments on commit 0d74990

Please sign in to comment.