diff options
author | Shaun McCance <shaunm@gnome.org> | 2010-05-10 10:48:29 -0500 |
---|---|---|
committer | Shaun McCance <shaunm@gnome.org> | 2010-05-10 14:00:32 -0500 |
commit | 12847b689b9d4e436940b213ca35c3b87401b545 (patch) | |
tree | 3bf226b6a140b3036847b76c292ae892753da8ae /libyelp | |
parent | 66ffe63eec59f0e5235b04625fd61e75bfb60587 (diff) | |
download | yelp-12847b689b9d4e436940b213ca35c3b87401b545.tar.gz |
[libyelp] Make relative links work for HTML documents
Diffstat (limited to 'libyelp')
-rw-r--r-- | libyelp/yelp-uri.c | 14 | ||||
-rw-r--r-- | libyelp/yelp-view.c | 9 |
2 files changed, 18 insertions, 5 deletions
diff --git a/libyelp/yelp-uri.c b/libyelp/yelp-uri.c index ee17b75a..7e76042c 100644 --- a/libyelp/yelp-uri.c +++ b/libyelp/yelp-uri.c @@ -482,7 +482,19 @@ resolve_file_path (YelpUri *uri) priv->gfile = g_file_new_for_path (path); } else if (base_priv && base_priv->gfile) { - priv->gfile = g_file_resolve_relative_path (base_priv->gfile, path); + GFileInfo *info; + info = g_file_query_info (base_priv->gfile, + G_FILE_ATTRIBUTE_STANDARD_TYPE, + G_FILE_QUERY_INFO_NONE, + NULL, NULL); + if (g_file_info_get_file_type (info) == G_FILE_TYPE_REGULAR) { + GFile *parent = g_file_get_parent (base_priv->gfile); + priv->gfile = g_file_resolve_relative_path (parent, path); + g_object_unref (parent); + } + else { + priv->gfile = g_file_resolve_relative_path (base_priv->gfile, path); + } } else { gchar *cur; diff --git a/libyelp/yelp-view.c b/libyelp/yelp-view.c index 767299b9..baf15bd7 100644 --- a/libyelp/yelp-view.c +++ b/libyelp/yelp-view.c @@ -560,13 +560,14 @@ view_navigation_requested (WebKitWebView *view, WebKitWebPolicyDecision *decision, gpointer user_data) { + const gchar *requri = webkit_network_request_get_uri (request); YelpViewPrivate *priv = GET_PRIV (view); YelpUri *uri; - debug_print (DB_FUNCTION, "entering\n"); - - uri = yelp_uri_new_relative (priv->uri, - webkit_network_request_get_uri (request)); + if (g_str_has_prefix (requri, BOGUS_URI)) + uri = yelp_uri_new_relative (priv->uri, requri + BOGUS_URI_LEN); + else + uri = yelp_uri_new_relative (priv->uri, requri); webkit_web_policy_decision_ignore (decision); |