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 PublicSuffixList

Remarks

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

NameDescription
LastUpdatedThe date of the version of the embedded list.
RuleCountThe number of rules of the embedded list.

The date of the version of the embedded list.

public static DateTimeOffset LastUpdated { get; }

Property value

DateTimeOffset

The number of rules of the embedded list.

public static int RuleCount { get; }

Property value

int

Methods

NameDescription
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.cs

Gets 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
domain ReadOnlySpan<char>
sources PublicSuffixRuleSources
Returns

string?

Remarks

When the domain matches no rule, the implicit * rule applies and the top-level domain is returned.

GetPublicSuffix(string?, PublicSuffixRuleSources)

PublicSuffixList.cs

Gets 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
domain string?
sources PublicSuffixRuleSources
Returns

string?

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.cs

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.

public static string? GetRegistrableDomain(ReadOnlySpan<char> domain, PublicSuffixRuleSources sources = PublicSuffixRuleSources.All)
Parameters
domain ReadOnlySpan<char>
sources PublicSuffixRuleSources
Returns

string?

GetRegistrableDomain(string?, PublicSuffixRuleSources)

PublicSuffixList.cs

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.

public static string? GetRegistrableDomain(string? domain, PublicSuffixRuleSources sources = PublicSuffixRuleSources.All)
Parameters
domain string?
sources PublicSuffixRuleSources
Returns

string?

IsPublicSuffix overloads

IsPublicSuffix(ReadOnlySpan<char>, PublicSuffixRuleSources)

PublicSuffixList.cs

Determines 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
domain ReadOnlySpan<char>
sources PublicSuffixRuleSources
Returns

bool

Remarks

Returns false for an unlisted top-level domain, even though the implicit * rule makes it a public suffix.

IsPublicSuffix(string?, PublicSuffixRuleSources)

PublicSuffixList.cs

Determines 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
domain string?
sources PublicSuffixRuleSources
Returns

bool

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.cs

Decomposes 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
domain ReadOnlySpan<char>
domainInfo DomainInfo
sources PublicSuffixRuleSources
Returns

bool false when the domain is not a valid domain name.

TryGetDomainInfo(string?, DomainInfo, PublicSuffixRuleSources)

PublicSuffixList.cs

Decomposes the domain into its public suffix, registrable domain, and subdomain.

public static bool TryGetDomainInfo(string? domain, out DomainInfo domainInfo, PublicSuffixRuleSources sources = PublicSuffixRuleSources.All)
Parameters
domain string?
domainInfo DomainInfo
sources PublicSuffixRuleSources
Returns

bool false when the domain is not a valid domain name.

TryGetDomainInfo(Uri, DomainInfo, PublicSuffixRuleSources)

PublicSuffixList.cs

Decomposes 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
uri Uri
domainInfo DomainInfo
sources PublicSuffixRuleSources
Returns

bool false when the host is not a domain name, such as an IP address.