publicsuffix_gleam
Types
Re-export DomainParts for public API
See domain.gleam for documentation.
pub type DomainParts =
domain.DomainParts
Errors that can occur during parsing
pub type ParseError {
InvalidUri
NoHost
InvalidDomain
UnknownSuffix
}
Constructors
-
InvalidUri -
NoHost -
InvalidDomain -
UnknownSuffix
Re-export SuffixList for public API
See suffix_list.gleam for documentation.
pub type SuffixList =
suffix_list.SuffixList
Values
pub fn load_suffix_list(
include_private: Bool,
) -> suffix_list.SuffixList
Load the public suffix list from the embedded data file and choose to include private domains or not.
Use this to pre-load the suffix list when parsing multiple URIs.
pub fn parse(
uri_string: String,
include_private: Bool,
) -> Result(domain.DomainParts, ParseError)
Parse a URI and extract domain parts
Note: This function loads the suffix list on every call. For better
performance when parsing multiple URIs, use parse_with_list() with
a cached suffix list.
pub fn parse_with_list(
uri_string: String,
list: suffix_list.SuffixList,
) -> Result(domain.DomainParts, ParseError)
Parse a URI and extract domain parts using a pre-loaded suffix list
For better performance when parsing multiple URIs, load the suffix list
once using load_suffix_list() and reuse it:
let list = load_suffix_list()
let result1 = parse_with_list("https://example.com", list)
let result2 = parse_with_list("https://test.co.uk", list)