aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ephy-string.c
diff options
context:
space:
mode:
authorDiego Escalante Urrelo <descalante@igalia.com>2010-02-11 00:59:07 +0800
committerDiego Escalante Urrelo <descalante@igalia.com>2010-02-11 03:14:32 +0800
commitfbf7c11f928a6f8aafb12601f211d54250b91a11 (patch)
tree6736ae7df61e5128c133729998c95c95970d76fb /lib/ephy-string.c
parent554c8839c7919e9ec188978f1c1fab24d06f9333 (diff)
downloadgsoc2013-epiphany-fbf7c11f928a6f8aafb12601f211d54250b91a11.tar
gsoc2013-epiphany-fbf7c11f928a6f8aafb12601f211d54250b91a11.tar.gz
gsoc2013-epiphany-fbf7c11f928a6f8aafb12601f211d54250b91a11.tar.bz2
gsoc2013-epiphany-fbf7c11f928a6f8aafb12601f211d54250b91a11.tar.lz
gsoc2013-epiphany-fbf7c11f928a6f8aafb12601f211d54250b91a11.tar.xz
gsoc2013-epiphany-fbf7c11f928a6f8aafb12601f211d54250b91a11.tar.zst
gsoc2013-epiphany-fbf7c11f928a6f8aafb12601f211d54250b91a11.zip
Use SoupURI to get host name in ephy-string
Bug #582035
Diffstat (limited to 'lib/ephy-string.c')
-rw-r--r--lib/ephy-string.c48
1 files changed, 10 insertions, 38 deletions
diff --git a/lib/ephy-string.c b/lib/ephy-string.c
index 7f7ec8481..0b07dc794 100644
--- a/lib/ephy-string.c
+++ b/lib/ephy-string.c
@@ -27,6 +27,7 @@
#include <glib.h>
#include <sys/types.h>
#include <pwd.h>
+#include <libsoup/soup.h>
#define ELLIPSIS "\xe2\x80\xa6"
@@ -448,47 +449,18 @@ ephy_string_canonicalize_pathname (const char *cpath)
char *
ephy_string_get_host_name (const char *url)
{
- const char *start;
- const char *p;
+ SoupURI *uri;
+ char *ret;
if (url == NULL || g_str_has_prefix (url, "file://")) return NULL;
-
- start = strstr (url, "//");
- if (start == NULL || start == '\0')
- {
- /* Not an URL */
- return NULL;
- }
- if (strlen (start) > 2)
- {
- /* Go past the protocol part */
- start = start + 2;
- }
- else
- {
- /* Not an URL again */
- return NULL;
- }
- p = strchr (start, '@');
- if (p != NULL)
- {
- /* We have a username:password@hostname scheme, skip it. */
- if (strlen (p) > 1) start = ++p;
- }
- p = strchr (start, ':');
- if (p != NULL)
- {
- /* hostname:port, skip port */
- return g_strndup (start, (p - start));
- }
- p = strchr (start, '/');
- if (p == NULL)
- {
- /* No more slashes in the url, we assume it's a host name */
- return g_strdup (start);
- }
- return g_strndup (start, (p - start));
+ uri = soup_uri_new (url);
+ if (uri == NULL) return NULL;
+
+ ret = g_strdup (uri->host);
+ soup_uri_free (uri);
+
+ return ret;
}
char *