Index: netsurf/utils/url.c
===================================================================
--- netsurf/utils/url.c	(revision 12242)
+++ netsurf/utils/url.c	(working copy)
@@ -856,6 +856,39 @@
 }
 
 /**
+ * Extract the gopher document type from an URL
+ *
+ * \param url     an absolute URL
+ * \param result  pointer to buffer to hold result
+ * \return URL_FUNC_OK on success
+ */
+
+url_func_result url_gopher_type(const char *url, char *result)
+{
+	url_func_result status;
+	struct url_components components;
+
+	assert(url);
+
+	status = url_get_components(url, &components);
+	if (status == URL_FUNC_OK) {
+		if (!components.path) {
+			status = URL_FUNC_FAILED;
+		} else {
+fprintf(stderr, "url_gopher_type: path: '%s'\n", components.path);
+			if (strlen(components.path) < 2)
+				*result = '1';
+			else if (components.path[0] == '/')
+				*result = components.path[1];
+			else
+				status = URL_FUNC_FAILED;
+		}
+	}
+	url_destroy_components(&components);
+	return status;
+}
+
+/**
  * Attempt to find a nice filename for a URL.
  *
  * \param  url	   an absolute URL
Index: netsurf/utils/url.h
===================================================================
--- netsurf/utils/url.h	(revision 12242)
+++ netsurf/utils/url.h	(working copy)
@@ -60,6 +60,7 @@
 url_func_result url_path(const char *url, char **result);
 url_func_result url_leafname(const char *url, char **result);
 url_func_result url_fragment(const char *url, char **result);
+url_func_result url_gopher_type(const char *url, char *result);
 url_func_result url_compare(const char *url1, const char *url2,
 		bool nofrag, bool *result);
 
