about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMarco Peereboom <marco@conformal.com>2011-08-24 21:50:13 +0000
committerMarco Peereboom <marco@conformal.com>2011-08-24 21:50:13 +0000
commitb1cb8202d246c4b815c949d90dc929f78d587f53 (patch)
treeab6998220e805634f0bf7eedeb4ebeeb9f69b3d9
parentc2ea997b62628d916d8684483b9ccd4e2a3c6e1f (diff)
downloadxombrero-b1cb8202d246c4b815c949d90dc929f78d587f53.tar.gz
Shuffle the about code into guess url because it really belongs there;
side-effect is that now one can use aliases in commands.

requested by mcbride
-rw-r--r--xxxterm.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/xxxterm.c b/xxxterm.c
index 2307993..528d4d9 100644
--- a/xxxterm.c
+++ b/xxxterm.c
@@ -1679,11 +1679,22 @@ guess_url_type(char *url_in)
 {
 	struct stat		sb;
 	char			*url_out = NULL, *enc_search = NULL;
+	int			i;
 
+	/* substitute aliases */
 	url_out = match_alias(url_in);
 	if (url_out != NULL)
 		return (url_out);
 
+	/* see if we are an about page */
+	if (!strncmp(url_in, XT_URI_ABOUT, XT_URI_ABOUT_LEN))
+		for (i = 0; i < LENGTH(about_list); i++)
+			if (!strcmp(&url_in[XT_URI_ABOUT_LEN],
+			    about_list[i].name)) {
+				url_out = g_strdup(url_in);
+				goto done;
+			}
+
 	if (guess_search && url_regex &&
 	    !(g_str_has_prefix(url_in, "http://") ||
 	    g_str_has_prefix(url_in, "https://"))) {
@@ -1728,6 +1739,11 @@ load_uri(struct tab *t, gchar *uri)
 
 	t->xtp_meaning = XT_XTP_TAB_MEANING_NORMAL;
 
+	if (valid_url_type(uri)) {
+		newuri = guess_url_type(uri);
+		uri = newuri;
+	}
+
 	if (!strncmp(uri, XT_URI_ABOUT, XT_URI_ABOUT_LEN)) {
 		for (i = 0; i < LENGTH(about_list); i++)
 			if (!strcmp(&uri[XT_URI_ABOUT_LEN], about_list[i].name)) {
@@ -1735,21 +1751,16 @@ load_uri(struct tab *t, gchar *uri)
 				about_list[i].func(t, &args);
 				gtk_widget_set_sensitive(GTK_WIDGET(t->stop),
 				    FALSE);
-				return;
+				goto done;
 			}
 		show_oops(t, "invalid about page");
-		return;
-	}
-
-	if (valid_url_type(uri)) {
-		newuri = guess_url_type(uri);
-		uri = newuri;
+		goto done;
 	}
 
 	set_status(t, (char *)uri, XT_STATUS_LOADING);
 	marks_clear(t);
 	webkit_web_view_load_uri(t->wv, uri);
-
+done:
 	if (newuri)
 		g_free(newuri);
 }