diff options
Diffstat (limited to 'src/url.c')
-rw-r--r-- | src/url.c | 16 |
1 files changed, 7 insertions, 9 deletions
@@ -658,28 +658,26 @@ char *a_Url_string_strip_delimiters(const char *str) } /* - * Is the provided hostname an IP address? + * What type of host is this? */ -bool_t a_Url_host_is_ip(const char *host) +int a_Url_host_type(const char *host) { uint_t len; if (!host || !*host) - return FALSE; + return URL_HOST_ERROR; len = strlen(host); if (len == strspn(host, "0123456789.")) { - _MSG("an IPv4 address\n"); - return TRUE; + return URL_HOST_IPV4; } if (strchr(host, ':') && (len == strspn(host, "0123456789abcdefABCDEF:."))) { /* The precise format is shown in section 3.2.2 of rfc 3986 */ - MSG("an IPv6 address\n"); - return TRUE; + return URL_HOST_IPV6; } - return FALSE; + return URL_HOST_NAME; } /* @@ -746,7 +744,7 @@ static const char *Url_host_find_public_suffix(const char *host) const char *s; uint_t dots; - if (!host || !*host || a_Url_host_is_ip(host)) + if (a_Url_host_type(host) != URL_HOST_NAME) return host; s = host; |