mirror of
https://github.com/google/nomulus.git
synced 2025-06-27 06:44:51 +02:00
Change second-level domain name to fully-qualified domain name
Second-level domain name isn't accurate because we support multi-part TLDs, so standardize on the "fullyQualifiedDomainName" name that is used throughout the code base. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=122693009
This commit is contained in:
parent
ca0e546230
commit
a2d2764115
14 changed files with 58 additions and 49 deletions
|
@ -43,8 +43,7 @@ public final class DomainNameUtils {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the canonicalized TLD part of a valid second level domain name by stripping off the
|
||||
* leftmost part.
|
||||
* Returns the canonicalized TLD part of a valid domain name by stripping off the leftmost part.
|
||||
*
|
||||
* <p>This function is compatible with multi-part tlds, e.g. {@code co.uk}. This function will
|
||||
* also work on domains for which the registry is not authoritative. If you are certain that the
|
||||
|
@ -52,26 +51,28 @@ public final class DomainNameUtils {
|
|||
* {@link google.registry.model.registry.Registries#findTldForName(InternetDomainName)
|
||||
* Registries#findTldForName}, which will work on hostnames in addition to domains.
|
||||
*
|
||||
* @param sld must be a punycode SLD (not a host or unicode)
|
||||
* @param fullyQualifiedDomainName must be a puny-coded domain name (not a subdomain or Unicode)
|
||||
* @throws IllegalArgumentException if there is no TLD
|
||||
*/
|
||||
public static String getTldFromSld(String sld) {
|
||||
checkArgument(!Strings.isNullOrEmpty(sld), "secondLevelDomainName cannot be null or empty");
|
||||
return getTldFromSld(InternetDomainName.from(sld));
|
||||
public static String getTldFromDomainName(String fullyQualifiedDomainName) {
|
||||
checkArgument(
|
||||
!Strings.isNullOrEmpty(fullyQualifiedDomainName),
|
||||
"fullyQualifiedDomainName cannot be null or empty");
|
||||
return getTldFromDomainName(InternetDomainName.from(fullyQualifiedDomainName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the canonicalized TLD part of a valid second level domain name by stripping off the
|
||||
* leftmost part.
|
||||
* Returns the canonicalized TLD part of a valid domain name by stripping off the leftmost part.
|
||||
*
|
||||
* <p>This function is compatible with multi-part tlds.
|
||||
* <p>This function is compatible with multi-part TLDs and must not be called with subdomains.
|
||||
*
|
||||
* @throws IllegalArgumentException if there is no TLD
|
||||
*/
|
||||
public static String getTldFromSld(InternetDomainName sld) {
|
||||
checkArgumentNotNull(sld);
|
||||
checkArgument(sld.hasParent(), "secondLevelDomainName does not have a TLD");
|
||||
return sld.parent().toString();
|
||||
public static String getTldFromDomainName(InternetDomainName fullyQualifiedDomainName) {
|
||||
checkArgumentNotNull(fullyQualifiedDomainName);
|
||||
checkArgument(
|
||||
fullyQualifiedDomainName.hasParent(), "fullyQualifiedDomainName does not have a TLD");
|
||||
return fullyQualifiedDomainName.parent().toString();
|
||||
}
|
||||
|
||||
private DomainNameUtils() {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue