PublicSuffixList Class
Provides access to an embedded snapshot of the Public Suffix List, which describes the part of a domain name that is not under the control of an individual registrant.
public static class PublicSuffixListRemarks
The list is compiled into the assembly, so no network access is performed. It is refreshed when a new version of the package is released.
Properties
| Name | Description |
|---|---|
| LastUpdated | The date of the version of the embedded list. |
| RuleCount | The number of rules of the embedded list. |
LastUpdated
PublicSuffixList.csThe date of the version of the embedded list.
public static DateTimeOffset LastUpdated { get; }Property value
RuleCount
PublicSuffixList.csMethods
| Name | Description |
|---|---|
| GetPublicSuffix(ReadOnlySpan<char>, PublicSuffixRuleSources) | Gets the public suffix (eTLD) of the domain, or null when the domain is not a valid domain name. |
| GetPublicSuffix(string?, PublicSuffixRuleSources) | Gets the public suffix (eTLD) of the domain, or null when the domain is not a valid domain name. |
| GetRegistrableDomain(ReadOnlySpan<char>, PublicSuffixRuleSources) | Gets the registrable domain (eTLD+1) of the domain, or null when the domain is not a valid domain name or is itself a public suffix. |
| GetRegistrableDomain(string?, PublicSuffixRuleSources) | Gets the registrable domain (eTLD+1) of the domain, or null when the domain is not a valid domain name or is itself a public suffix. |
| IsPublicSuffix(ReadOnlySpan<char>, PublicSuffixRuleSources) | Determines whether the domain is a public suffix, that is whether it matches a rule of the list. |
| IsPublicSuffix(string?, PublicSuffixRuleSources) | Determines whether the domain is a public suffix, that is whether it matches a rule of the list. |
| TryGetDomainInfo(ReadOnlySpan<char>, DomainInfo, PublicSuffixRuleSources) | Decomposes the domain into its public suffix, registrable domain, and subdomain. |
| TryGetDomainInfo(string?, DomainInfo, PublicSuffixRuleSources) | Decomposes the domain into its public suffix, registrable domain, and subdomain. |
| TryGetDomainInfo(Uri, DomainInfo, PublicSuffixRuleSources) | Decomposes the host of the URI into its public suffix, registrable domain, and subdomain. |
GetPublicSuffix overloads
GetPublicSuffix(ReadOnlySpan<char>, PublicSuffixRuleSources)
PublicSuffixList.csGets the public suffix (eTLD) of the domain, or null when the domain is not a valid domain name.
public static string? GetPublicSuffix(ReadOnlySpan<char> domain, PublicSuffixRuleSources sources = PublicSuffixRuleSources.All)Parameters
domainReadOnlySpan<char>sourcesPublicSuffixRuleSources
Returns
Remarks
When the domain matches no rule, the implicit * rule applies and the top-level domain is returned.
GetPublicSuffix(string?, PublicSuffixRuleSources)
PublicSuffixList.csGets the public suffix (eTLD) of the domain, or null when the domain is not a valid domain name.
public static string? GetPublicSuffix(string? domain, PublicSuffixRuleSources sources = PublicSuffixRuleSources.All)Parameters
domainstring?sourcesPublicSuffixRuleSources
Returns
Remarks
When the domain matches no rule, the implicit * rule applies and the top-level domain is returned.
GetRegistrableDomain overloads
GetRegistrableDomain(ReadOnlySpan<char>, PublicSuffixRuleSources)
PublicSuffixList.csGets the registrable domain (eTLD+1) of the domain, or null when the domain is not a valid domain name or is itself a public suffix.
public static string? GetRegistrableDomain(ReadOnlySpan<char> domain, PublicSuffixRuleSources sources = PublicSuffixRuleSources.All)GetRegistrableDomain(string?, PublicSuffixRuleSources)
PublicSuffixList.csGets the registrable domain (eTLD+1) of the domain, or null when the domain is not a valid domain name or is itself a public suffix.
public static string? GetRegistrableDomain(string? domain, PublicSuffixRuleSources sources = PublicSuffixRuleSources.All)IsPublicSuffix overloads
IsPublicSuffix(ReadOnlySpan<char>, PublicSuffixRuleSources)
PublicSuffixList.csDetermines whether the domain is a public suffix, that is whether it matches a rule of the list.
public static bool IsPublicSuffix(ReadOnlySpan<char> domain, PublicSuffixRuleSources sources = PublicSuffixRuleSources.All)Parameters
domainReadOnlySpan<char>sourcesPublicSuffixRuleSources
Returns
Remarks
Returns false for an unlisted top-level domain, even though the implicit * rule makes it a public suffix.
IsPublicSuffix(string?, PublicSuffixRuleSources)
PublicSuffixList.csDetermines whether the domain is a public suffix, that is whether it matches a rule of the list.
public static bool IsPublicSuffix(string? domain, PublicSuffixRuleSources sources = PublicSuffixRuleSources.All)Parameters
domainstring?sourcesPublicSuffixRuleSources
Returns
Remarks
Returns false for an unlisted top-level domain, even though the implicit * rule makes it a public suffix.
TryGetDomainInfo overloads
TryGetDomainInfo(ReadOnlySpan<char>, DomainInfo, PublicSuffixRuleSources)
PublicSuffixList.csDecomposes the domain into its public suffix, registrable domain, and subdomain.
public static bool TryGetDomainInfo(ReadOnlySpan<char> domain, out DomainInfo domainInfo, PublicSuffixRuleSources sources = PublicSuffixRuleSources.All)Parameters
domainReadOnlySpan<char>domainInfoDomainInfosourcesPublicSuffixRuleSources
Returns
bool false when the domain is not a valid domain name.
TryGetDomainInfo(string?, DomainInfo, PublicSuffixRuleSources)
PublicSuffixList.csDecomposes the domain into its public suffix, registrable domain, and subdomain.
public static bool TryGetDomainInfo(string? domain, out DomainInfo domainInfo, PublicSuffixRuleSources sources = PublicSuffixRuleSources.All)Parameters
domainstring?domainInfoDomainInfosourcesPublicSuffixRuleSources
Returns
bool false when the domain is not a valid domain name.
TryGetDomainInfo(Uri, DomainInfo, PublicSuffixRuleSources)
PublicSuffixList.csDecomposes the host of the URI into its public suffix, registrable domain, and subdomain.
public static bool TryGetDomainInfo(Uri uri, out DomainInfo domainInfo, PublicSuffixRuleSources sources = PublicSuffixRuleSources.All)Parameters
uriUridomainInfoDomainInfosourcesPublicSuffixRuleSources
Returns
bool false when the host is not a domain name, such as an IP address.