]> spindle.queued.net Git - midori/commitdiff
Append the search term if a search lacks a '%s'
authorChristian Dywan <christian@twotoasts.de>
Fri, 2 Jan 2009 22:15:01 +0000 (23:15 +0100)
committerChristian Dywan <christian@twotoasts.de>
Fri, 2 Jan 2009 22:16:38 +0000 (23:16 +0100)
midori/sokoke.c
tests/magic-uri.c

index 2071f7340880307ef3ebaded5bbaac6a03e30e9b..54f946e8c4c7faddba3f59bd830a46d0f22ba010 100644 (file)
@@ -187,7 +187,12 @@ sokoke_magic_uri (const gchar* uri,
         }
         g_free (parts);
         if (search_uri)
-            search = g_strdup_printf (search_uri, parts[1]);
+        {
+            if (strstr (search_uri, "%s"))
+                search = g_strdup_printf (search_uri, parts[1]);
+            else
+                search = g_strdup_printf ("%s%s", search_uri, parts[1]);
+        }
         return search;
     }
     return g_strdup (uri);
index 7fda317a558919863614c6510410eb96bc0faf85..5192fac31120270f2b6a5c3de40df43948cfa386 100644 (file)
@@ -32,6 +32,12 @@ main (int    argc,
                          "uri", "http://www.searchmash.com/search/%s",
                          "token", "sm", NULL);
     katze_array_add_item (search_engines, item);
+    g_object_unref (item);
+    item = g_object_new (KATZE_TYPE_ITEM,
+                         "uri", "http://www.searchmash.com/search/",
+                         "token", "se", NULL);
+    katze_array_add_item (search_engines, item);
+    g_object_unref (item);
 
 #define test_input(input, expected) \
   uri = sokoke_magic_uri (input, search_engines); \
@@ -65,6 +71,7 @@ main (int    argc,
     test_input ("192.168.1.1:8000", "http://192.168.1.1:8000");
     test_input ("sm midori", SM "midori");
     test_input ("sm cats dogs", SM "cats dogs");
+    test_input ("se cats dogs", SM "cats dogs");
     test_input ("dict midori", NULL);
     test_input ("cats", NULL);
     test_input ("cats dogs", NULL);