Don't mixup tokens starting with the same letters
This commit is contained in:
parent
2e17639201
commit
e5da45a40e
2 changed files with 19 additions and 2 deletions
|
@ -404,8 +404,13 @@ katze_array_find_token (KatzeArray* array,
|
|||
for (items = array->items; items; items = g_list_next (items))
|
||||
{
|
||||
const gchar* found_token = ((KatzeItem*)items->data)->token;
|
||||
if (found_token != NULL && !strncmp (token, found_token, token_length))
|
||||
return items->data;
|
||||
if (found_token != NULL)
|
||||
{
|
||||
guint bigger_item = strlen (found_token) > token_length ? strlen (found_token) : token_length;
|
||||
|
||||
if (strncmp (token, found_token, bigger_item) == 0)
|
||||
return items->data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,16 @@ test_input (const gchar* input,
|
|||
"token", "se", NULL);
|
||||
katze_array_add_item (search_engines, item);
|
||||
g_object_unref (item);
|
||||
item = g_object_new (KATZE_TYPE_ITEM,
|
||||
"uri", "ddg.gg",
|
||||
"token", "dd", NULL);
|
||||
katze_array_add_item (search_engines, item);
|
||||
g_object_unref (item);
|
||||
item = g_object_new (KATZE_TYPE_ITEM,
|
||||
"uri", "google.com",
|
||||
"token", "d", NULL);
|
||||
katze_array_add_item (search_engines, item);
|
||||
g_object_unref (item);
|
||||
}
|
||||
|
||||
uri = sokoke_magic_uri (input);
|
||||
|
@ -160,6 +170,8 @@ static void
|
|||
magic_uri_search (void)
|
||||
{
|
||||
test_input ("sm midori", SM "midori");
|
||||
test_input ("d midori browser", "google.com" "midori%20browser");
|
||||
test_input ("dd midori browser", "ddg.gg" "midori%20browser");
|
||||
test_input ("sm cats dogs", SM "cats%20dogs");
|
||||
test_input ("se cats dogs", SM "cats%20dogs");
|
||||
test_input ("dict midori", NULL);
|
||||
|
|
Loading…
Reference in a new issue