publicsuffix_gleam/domain
Types
Represents the parsed components of a domain Definitions top_level_domain or TLD is the last part of a domain name before the paths. For example, in https://packages.gleam.run, “run” is the TLD.
second_level_domain or SLD is the part of a domain name before the TLD, separated by a “.”. For example, in https://packages.gleam.run, “gleam” is the SLD.
transit_routing_domain or TRD is the first part of a domain name and may have more than one part. For example, in https://packages.gleam.run, “packages” is the TRD and in https://cool.packages.gleam.run “cool.packages” is the TRD.
We return “subdomain_parts” that splits the TRD on “.”.
pub type DomainParts {
DomainParts(
top_level_domain: String,
second_level_domain: String,
transit_routing_domain: String,
subdomain_parts: List(String),
)
}
Constructors
-
DomainParts( top_level_domain: String, second_level_domain: String, transit_routing_domain: String, subdomain_parts: List(String), )
Error type for domain extraction
pub type ExtractionError {
InvalidDomain
}
Constructors
-
InvalidDomain
Values
pub fn extract_parts(
host: String,
suffix: String,
) -> Result(DomainParts, ExtractionError)
Extract domain parts from hostname and suffix