37#ifndef TLD_URLPARSER_H
38#define TLD_URLPARSER_H
45#ifndef PUBLIC_SUFFIX_LIST_DAT
46#define PUBLIC_SUFFIX_LIST_DAT "public_suffix_list.dat"
80 static std::
string extractHost(const std::
string& url) noexcept;
95 Url() noexcept = default;
102 bool operator==(const
Url& other) const;
108 std::
string str() const noexcept;
126 const std::
string&
domain() const noexcept;
132 const std::
string&
suffix() const noexcept;
138 const std::
string&
query() const noexcept;
174 const
int port() const noexcept;
190 std::shared_ptr<Impl> impl;
236 static std::string_view removeWWW(const std::string_view&
host) noexcept;
258 bool operator==(const
Host& other) const;
265 bool operator==(const std::
string& other) const;
271 const std::
string&
suffix() const noexcept;
277 const std::
string&
domain() const noexcept;
301 const std::
string&
str() const noexcept;
305 std::shared_ptr<Impl> impl;
323std::ostream& operator<<(std::ostream& os, const
TLD::
Url& dt);
331std::ostream& operator<<(std::ostream& os, const
TLD::Host& dt);
Represents a Host part of a URL.
Definition urlparser.h:200
static Host fromUrl(const std::string &url, const bool ignore_www=DEFAULT_IGNORE_WWW)
Create a Host object from a URL string.
static void loadPslFromPath(const std::string &filepath)
Load the Public Suffix List from a file.
static void loadPslFromString(const std::string &filestr)
Load the Public Suffix List from a string.
static bool isPslLoaded() noexcept
Check if the Public Suffix List (PSL) is loaded.
Represents a URL.
Definition urlparser.h:67
static std::string extractHost(const std::string &url) noexcept
Extract the host from a given URL.
static bool isPslLoaded() noexcept
Check if the Public Suffix List (PSL) is loaded.
const std::string & protocol() const noexcept
Get the protocol of the URL.
const std::string & query() const noexcept
Get the query part of the URL.
const std::string & userinfo() const noexcept
Get the userinfo part of the URL.
const std::string & fulldomain() const noexcept
Get the full domain of the URL.
const std::string & suffix() const noexcept
Get the suffix of the URL.
const std::string & fragment() const noexcept
Get the fragment part of the URL.
const int port() const noexcept
Get the port of the URL.
std::string domainName() const noexcept
Get the domain name of the URL.
const Host & host() const
Get the host object of the URL.
QueryParams params() const noexcept
Get the parameters of the URL.
Url() noexcept=default
Default constructor for the Url class. Creates an empty URL object.
const std::string & domain() const noexcept
Get the domain of the URL.
const std::string & subdomain() const noexcept
Get the subdomain of the URL.
std::string str() const noexcept
Get the complete URL as a string.
std::string abspath() const noexcept
Get the absolute path of the URL.
Definition urlparser.h:49
std::vector< std::string > QueryParams
A vector of strings representing query parameters in a URL.
Definition urlparser.h:56
constexpr bool DEFAULT_IGNORE_WWW
Definition urlparser.h:50