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;
}
"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);
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);