From 3c75e9eb20d9ff12150c65eeeab0a1187324bc45 Mon Sep 17 00:00:00 2001 From: Dale Whittaker Date: Tue, 27 Jan 2009 18:56:21 +0100 Subject: [PATCH] Prevent duplicate entries by looking for trailing slashes --- midori/midori-locationaction.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/midori/midori-locationaction.c b/midori/midori-locationaction.c index 6c966b48..bdcfce06 100644 --- a/midori/midori-locationaction.c +++ b/midori/midori-locationaction.c @@ -592,17 +592,28 @@ midori_location_action_iter_lookup (MidoriLocationAction* location_action, GtkTreeIter* iter) { gchar* path; + gchar* new_uri; + gboolean found; - if ((path = g_hash_table_lookup (location_action->items, uri))) + found = FALSE; + new_uri = NULL; + + if (!g_str_has_suffix (uri, "/")) + new_uri = g_strconcat (uri, "/", NULL); + + if ((path = g_hash_table_lookup (location_action->items, + new_uri ? new_uri : uri))) { - if (gtk_tree_model_get_iter_from_string (location_action->model, - iter, path)) - return TRUE; - - g_hash_table_remove (location_action->items, uri); + if (!(found = gtk_tree_model_get_iter_from_string (location_action->model, + iter, path))) + { + g_hash_table_remove (location_action->items, + new_uri ? new_uri : uri); + } } + g_free (new_uri); - return FALSE; + return found; } /**