Skip to content

okhttp / okhttp3 / HttpUrl / topPrivateDomain

topPrivateDomain

fun topPrivateDomain():String?

Returns the domain name of this URL’s host that is one level beneath the public suffix by consulting the public suffix list. Returns null if this URL’s host is an IP address or is considered a public suffix by the public suffix list.

In general this method should not be used to test whether a domain is valid or routable. Instead, DNS is the recommended source for that information.

URL topPrivateDomain()
http://google.com "google.com"
http://adwords.google.co.uk "google.co.uk"
http://square null
http://co.uk null
http://localhost null
http://127.0.0.1 null