[yelp/webkit] Make references work, by massaging the anchor URIs



commit b4a68d7441671bd6165ef30af6303cf968c797e2
Author: Gustavo Noronha Silva <gns gnome org>
Date:   Tue Aug 18 19:52:22 2009 -0300

    Make references work, by massaging the anchor URIs
    
    We need to get the anchor that is being clicked, and replace the name
    that goes after the question mark using it before we pass the URI
    along in our signals.

 src/yelp-html.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/src/yelp-html.c b/src/yelp-html.c
index eca02a5..bc07c37 100644
--- a/src/yelp-html.c
+++ b/src/yelp-html.c
@@ -89,6 +89,24 @@ html_open_uri (WebKitWebView* view,
 
     real_uri = g_strdup (uri);
 
+    /* If we got an URI with an anchor, that means we got to a
+     * reference; we want to get what comes after #, and replace what
+     * is after ? in the base URI we have
+     */
+    if (g_str_has_prefix (uri, html->priv->base_uri)) {
+	gint length = strlen (html->priv->base_uri);
+
+	if (uri[length] == '#') {
+	    gchar *question_mark = g_strrstr (real_uri, "?");
+	    gchar *tmp = real_uri;
+
+	    *question_mark = '\0';
+	    real_uri = g_strdup_printf ("%s?%s", tmp, uri + length + 1);
+
+	    g_free (tmp);
+	}
+    }
+
     if (!html->priv->frames_enabled) {
   	g_signal_emit (html, signals[URI_SELECTED], 0, real_uri, FALSE);
     } else {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]