From c9e188a4d1634d9c7d2292a8d04e02f313f37f3b Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sat, 25 Oct 2003 19:20:13 +0000 Subject: [project @ 2003-10-25 19:20:13 by jmb] HTTP Auth login improved (greatly). Addresses all three issues in the previous version. svn path=/import/netsurf/; revision=382 --- utils/utils.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'utils/utils.c') diff --git a/utils/utils.c b/utils/utils.c index bc912fdc7..ca7d7f2fc 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -197,14 +197,14 @@ char *url_join(const char* new, const char* base) nn[j] = new[i]; k = j; } - + j++; } if(k < j){ nn[k+1] = '\0'; LOG(("before: %s after: %s", new, nn)); } - + new = nn; if (base == 0) @@ -252,7 +252,26 @@ char *url_join(const char* new, const char* base) strcpy(ret, new); } - xfree(nn); + xfree(nn); return ret; } +char *get_host_from_url (char *url) { + + char *host = xcalloc(strlen(url)+10, sizeof(char)); + int i; + + i = strspn(url, "abcdefghijklmnopqrstuvwxyz"); + if (url[i] == ':') { + strcpy(host, url); + i += 3; + } + + for (; host[i] != 0 && host[i] != '/'; i++) + host[i] = tolower(host[i]); + + host[i] = '/'; + host[i+1] = 0; + + return host; +} -- cgit v1.2.3