diff options
Diffstat (limited to 'utils/utils.c')
-rw-r--r-- | utils/utils.c | 25 |
1 files changed, 22 insertions, 3 deletions
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; +} |