Loading...
Searching...
No Matches
urlparser::psl Class Reference

#include <urlparser.h>

+ Collaboration diagram for urlparser::psl:

Public Member Functions

bool is_loaded () const noexcept
 Whether a PSL is currently loaded (true even for the bundled default).
 
bool is_suffix (std::string_view text) const noexcept
 Check whether text is itself a recognized public suffix (e.g. "co.uk", "com") - not the suffix of some hostname the way suffix_of() extracts one, but whether this exact text is a listed entry. Unlike suffix_of()'s fallback for unknown TLDs, an unrecognized word like "comm" correctly returns false here.
 
void load_from_path (const std::string &filepath)
 Load the Public Suffix List from a file, replacing whatever was loaded before (including the bundled default).
 
void load_from_string (const std::string &filestr)
 Load the Public Suffix List from a string, replacing whatever was loaded before (including the bundled default).
 
std::string_view source_url () const noexcept
 The URL the bundled PSL data was downloaded from.
 
std::string suffix_of (const std::string &hostname_text) const
 The public suffix of a hostname (e.g. "co.uk" for "example.co.uk"), with a best-effort single-label fallback when the TLD isn't recognized (e.g. "comm" for "example.comm") - this is what hostname::suffix() uses. Works for punycoded or unpunycoded hostnames (but not mixed).
 
std::string_view version () const noexcept
 The "// VERSION: ..." timestamp from the loaded PSL data, empty if absent.
 

Static Public Member Functions

static psl & instance () noexcept
 The one, lazily-built, shared PSL instance.
 

Member Function Documentation

◆ instance()

static psl & urlparser::psl::instance ( )
staticnoexcept

The one, lazily-built, shared PSL instance.

◆ is_loaded()

bool urlparser::psl::is_loaded ( ) const
noexcept

Whether a PSL is currently loaded (true even for the bundled default).

◆ is_suffix()

bool urlparser::psl::is_suffix ( std::string_view  text) const
noexcept

Check whether text is itself a recognized public suffix (e.g. "co.uk", "com") - not the suffix of some hostname the way suffix_of() extracts one, but whether this exact text is a listed entry. Unlike suffix_of()'s fallback for unknown TLDs, an unrecognized word like "comm" correctly returns false here.

◆ load_from_path()

void urlparser::psl::load_from_path ( const std::string &  filepath)

Load the Public Suffix List from a file, replacing whatever was loaded before (including the bundled default).

Exceptions
std::invalid_argumentIf the file cannot be opened or parsed.

◆ load_from_string()

void urlparser::psl::load_from_string ( const std::string &  filestr)

Load the Public Suffix List from a string, replacing whatever was loaded before (including the bundled default).

Exceptions
std::invalid_argumentIf the content cannot be parsed.

◆ source_url()

std::string_view urlparser::psl::source_url ( ) const
noexcept

The URL the bundled PSL data was downloaded from.

◆ suffix_of()

std::string urlparser::psl::suffix_of ( const std::string &  hostname_text) const

The public suffix of a hostname (e.g. "co.uk" for "example.co.uk"), with a best-effort single-label fallback when the TLD isn't recognized (e.g. "comm" for "example.comm") - this is what hostname::suffix() uses. Works for punycoded or unpunycoded hostnames (but not mixed).

◆ version()

std::string_view urlparser::psl::version ( ) const
inlinenoexcept

The "// VERSION: ..." timestamp from the loaded PSL data, empty if absent.


The documentation for this class was generated from the following file: