diff options
author | Carlos Garcia Campos <cgarcia@igalia.com> | 2015-06-15 20:10:21 +0200 |
---|---|---|
committer | Carlos Garcia Campos <carlosgc@gnome.org> | 2015-06-16 12:47:20 +0200 |
commit | dfc65b091f7d1c2cc95e32ac0fd147f06a0c7c58 (patch) | |
tree | 604f7b2ba456e751b6d6867204df61309d42da68 | |
parent | 9c3466691c6d6cd6676f911d56756408aa748c0e (diff) | |
download | yelp-dfc65b091f7d1c2cc95e32ac0fd147f06a0c7c58.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.c | 30 |
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; } |