Package google.registry.util
Class DomainNameUtils
java.lang.Object
google.registry.util.DomainNameUtils
Utility methods related to domain names.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
canonicalizeHostname
(String label) Canonicalizes a hostname/domain name by lowercasing and converting unicode to punycode.static String
getSecondLevelDomain
(String hostName, String tld) Returns the second level domain name for a fully qualified host name under a given tld.static String
getTldFromDomainName
(com.google.common.net.InternetDomainName domainName) Returns the canonicalized TLD part of a valid fully-qualified domain name by stripping off the leftmost part.static String
getTldFromDomainName
(String domainName) Returns the canonicalized TLD part of a valid fully-qualified domain name by stripping off the leftmost part.static boolean
isUnder
(com.google.common.net.InternetDomainName name, com.google.common.net.InternetDomainName potentialParent) Checks whether "name" is a strict subdomain of "potentialParent".
-
Field Details
-
ACE_PREFIX
Prefix for unicode domain name parts.- See Also:
-
ACE_PREFIX_REGEX
- See Also:
-
-
Method Details
-
isUnder
public static boolean isUnder(com.google.common.net.InternetDomainName name, com.google.common.net.InternetDomainName potentialParent) Checks whether "name" is a strict subdomain of "potentialParent". -
canonicalizeHostname
Canonicalizes a hostname/domain name by lowercasing and converting unicode to punycode. -
getTldFromDomainName
Returns the canonicalized TLD part of a valid fully-qualified domain name by stripping off the leftmost part.This method should not be called for subdomains.
This function is compatible with multi-part tlds, e.g.
co.uk
. This function will also work on domains for which the registry is not authoritative. If you are certain that the input will be under a TLD this registry controls, then it is preferable to useRegistries#findTldForName
, which will work on hostnames in addition to domains.- Parameters:
domainName
- must be a punycode SLD (not a host or unicode)- Throws:
IllegalArgumentException
- if there is no TLD
-
getTldFromDomainName
Returns the canonicalized TLD part of a valid fully-qualified domain name by stripping off the leftmost part.This function is compatible with multi-part TLDs and should not be called with subdomains.
- Throws:
IllegalArgumentException
- if there is no TLD
-
getSecondLevelDomain
Returns the second level domain name for a fully qualified host name under a given tld.This function is merely a string parsing utility, and does not verify if the tld is operated by the registry.
- Throws:
IllegalArgumentException
- if either argument is null or empty, or the domain name is not under the tld
-