summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun McCance <shaunm@gnome.org>2010-05-10 10:48:29 -0500
committerShaun McCance <shaunm@gnome.org>2010-05-10 14:00:32 -0500
commit12847b689b9d4e436940b213ca35c3b87401b545 (patch)
tree3bf226b6a140b3036847b76c292ae892753da8ae
parent66ffe63eec59f0e5235b04625fd61e75bfb60587 (diff)
downloadyelp-12847b689b9d4e436940b213ca35c3b87401b545.tar.gz
[libyelp] Make relative links work for HTML documents
-rw-r--r--libyelp/yelp-uri.c14
-rw-r--r--libyelp/yelp-view.c9
-rw-r--r--tests/test-uri.c4
3 files changed, 20 insertions, 7 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);
diff --git a/tests/test-uri.c b/tests/test-uri.c
index 869d9b1c..d2889999 100644
--- a/tests/test-uri.c
+++ b/tests/test-uri.c
@@ -35,7 +35,7 @@ static void
print_uri (gchar *orig, YelpUri *uri, GOutputStream *stream)
{
GFile *file;
- gchar *type, *tmp, **tmpv, *out;
+ gchar *type = NULL, *tmp, **tmpv, *out;
g_output_stream_write (stream, orig, strlen (orig), NULL, NULL);
g_output_stream_write (stream, "\n", 1, NULL, NULL);
@@ -199,7 +199,7 @@ run_all_tests (int argc, char **argv)
G_FILE_ATTRIBUTE_STANDARD_NAME);
if (!g_str_has_suffix (name, ".test"))
continue;
- list = g_list_insert_sorted (list, name, strcmp);
+ list = g_list_insert_sorted (list, (gchar *) name, (GCompareFunc) strcmp);
}
while (list) {