### Function

# Soup tld_get_base_domain

#### Declaration [src]

    const char*
    soup_tld_get_base_domain (
      const char* hostname,
      GError** error
    )

#### Description [src]

Finds the base domain for a given `hostname`

The base domain is composed by the top level domain (such as .org, .com, .co.uk, etc) plus the second level domain, for example for myhost.mydomain.com it will return mydomain.com.

Note that `NULL` will be returned for private URLs (those not ending with any well known TLD) because choosing a base domain for them would be totally arbitrary.

Prior to libsoup 2.46, this function required that `hostname` be in UTF-8 if it was an IDN. From 2.46 on, the name can be in either UTF-8 or ASCII format (and the return value will be in the same format).

#### Parameters

`hostname`

  Type: `const char*`

  A hostname.

  The data is owned by the caller of the function.
  The value is a NUL terminated UTF-8 string.

`error`

  Type: `GError **`

  The return location for a recoverable error.

  The argument can be `NULL`.
  If the return location is not `NULL`, then you must initialize it to a `NULL` `GError*`.
  The argument will left initialized to `NULL` by the function if there are no errors.
  In case of error, the argument will be set to a newly allocated `GError`; the caller will take ownership of the data, and be responsible for freeing it.

#### Return value

Type: `const char*`

A pointer to the start of the base domain in `hostname`. If an error occurs, `NULL` will be returned and `error` set.

The data is owned by the called function.
The value is a NUL terminated UTF-8 string.