summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2015-06-15 20:10:21 +0200
committerDavid King <amigadave@amigadave.com>2015-06-22 14:56:04 +0100
commit83abdc8259030cbff97321186384ca6e9c809a8f (patch)
tree1dc8958340fc33e3db7cce8fc4c05298ac147bd8
parent139eebcb8354d947f8446d1236da3f60cf1e24d3 (diff)
downloadyelp-83abdc8259030cbff97321186384ca6e9c809a8f.tar.gz
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.
-rw-r--r--libyelp/yelp-uri-builder.c30
1 files 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;
}