From dfc65b091f7d1c2cc95e32ac0fd147f06a0c7c58 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Mon, 15 Jun 2015 20:10:21 +0200 Subject: yelp-uri-builder: Handle info uris info uris were not handled by build_network_uri and build_yelp_uri. We need to make sure they are valid network URIs from the WebKit point of view, like we do for other URIs, but we also need to handle the fragment part differently. When navigating from info:bar to info:foo#bar, WEbKoit doesn't start a new load, since it's considered a navigation inside the same already loaded page. So, we need to make WebKit think this is a new path, so that the load happens and the new section is resolved and loaded. To do this we just replace the '#' by '/' in build_network_uri and the '/' by '#' in build_yelp_uri. --- libyelp/yelp-uri-builder.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/libyelp/yelp-uri-builder.c b/libyelp/yelp-uri-builder.c index e2b670e7..7022f98b 100644 --- a/libyelp/yelp-uri-builder.c +++ b/libyelp/yelp-uri-builder.c @@ -36,8 +36,15 @@ build_network_uri (const gchar *uri) * help: and ghelp: URIs to be considered as absolute by WebKit. */ if (g_str_equal (soup_uri->scheme, "ghelp") || g_str_equal (soup_uri->scheme, "gnome-help") || - g_str_equal (soup_uri->scheme, "help") || g_str_equal (soup_uri->scheme, "help-list")) { - path = g_strdup_printf ("/%s", soup_uri->path); + g_str_equal (soup_uri->scheme, "help") || g_str_equal (soup_uri->scheme, "help-list") || + g_str_equal (soup_uri->scheme, "info")) { + + if (g_str_equal (soup_uri->scheme, "info") && soup_uri->fragment) { + path = g_strdup_printf ("/%s/%s", soup_uri->path, soup_uri->fragment); + soup_uri_set_fragment (soup_uri, NULL); + } else { + path = g_strdup_printf ("/%s", soup_uri->path); + } soup_uri_set_path (soup_uri, path); g_free (path); } @@ -65,13 +72,8 @@ build_yelp_uri (const gchar *uri_str) int path_len; gchar *uri = g_strdup (uri_str); - if (!g_str_has_prefix (uri, BOGUS_PREFIX "ghelp:/") && - !g_str_has_prefix (uri, BOGUS_PREFIX "gnome-help:/") && - !g_str_has_prefix (uri, BOGUS_PREFIX "help:/") && - !g_str_has_prefix (uri, BOGUS_PREFIX "help-list:/")) - { - return uri; - } + if (!g_str_has_prefix (uri, BOGUS_PREFIX)) + return uri; memmove (uri, uri + BOGUS_PREFIX_LEN, strlen (uri) - BOGUS_PREFIX_LEN + 1); @@ -80,11 +82,19 @@ build_yelp_uri (const gchar *uri_str) resource++; memmove (resource, resource + 1, strlen (resource)); - /*Remove the last / if any */ + /* Remove the trailing slash if any */ path_len = strlen (uri); if (uri[path_len - 1] == '/') uri[path_len - 1] = '\0'; + if (g_str_has_prefix (uri, "info:")) { + gchar *frag; + + frag = g_strrstr (uri, "/"); + if (frag) + frag[0] = '#'; + } + return uri; } -- cgit v1.2.1