char * name;
const char * dot = strrchr( host, '.' );
- if( dot == NULL )
+ if( tr_addressIsIP( host ) )
name = g_strdup( host );
- else
+ else if( dot )
name = g_strndup( host, dot - host );
+ else
+ name = g_strdup( host );
*name = g_ascii_toupper( *name );
{
char * h = NULL;
char * name;
- const char * first_dot;
- const char * last_dot;
tr_urlParse( url, -1, NULL, &h, NULL, NULL );
- first_dot = strchr( h, '.' );
- last_dot = strrchr( h, '.' );
- if( ( first_dot ) && ( last_dot ) && ( first_dot != last_dot ) )
- name = g_strdup( first_dot + 1 );
- else
+ if( tr_addressIsIP( h ) )
name = g_strdup( h );
+ else {
+ const char * first_dot = strchr( h, '.' );
+ const char * last_dot = strrchr( h, '.' );
+ if( ( first_dot ) && ( last_dot ) && ( first_dot != last_dot ) )
+ name = g_strdup( first_dot + 1 );
+ else
+ name = g_strdup( h );
+ }
tr_free( h );
return name;