/* * Copyright (c) 2024, Shannon Booth * Copyright (c) 2024, Sam Atkins * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include namespace URL { // https://url.spec.whatwg.org/#concept-host // A host is a domain, an IP address, an opaque host, or an empty host. Typically a host serves as a network address, // but it is sometimes used as opaque identifier in URLs where a network address is not necessary. class Host { public: using VariantType = Variant; Host(VariantType&&); Host(String&&); bool is_domain() const; bool is_empty_host() const; template bool has() const { return m_value.template has(); } template T const& get() const { return m_value.template get(); } bool operator==(Host const& other) const = default; VariantType const& value() const { return m_value; } Optional public_suffix() const; Optional registrable_domain() const; String serialize() const; private: VariantType m_value; }; }