#pragma once #include #include #include #include #include #include namespace Echoion::Api::Plugin::ShortUrl { template using Result = std::expected; [[nodiscard]] Result parseConfigObject(const char* config); [[nodiscard]] Result requireString(const Void::Json::Value& object, std::string_view key); [[nodiscard]] Result optionalString(const Void::Json::Value& object, std::string_view key, std::string_view fallback = {}); [[nodiscard]] Result optionalBool(const Void::Json::Value& object, std::string_view key, bool fallback); [[nodiscard]] Result optionalInteger(const Void::Json::Value& object, std::string_view key, std::int64_t fallback, std::int64_t minimum, std::int64_t maximum); [[nodiscard]] bool containsControlCharacters(std::string_view value) noexcept; [[nodiscard]] std::string trimAscii(std::string_view value); [[nodiscard]] bool isHeaderName(std::string_view value) noexcept; [[nodiscard]] bool isBase62(std::string_view value) noexcept; /// Validate an absolute HTTP(S) URL without making a network request. [[nodiscard]] Result validateHttpUrl(std::string_view value, bool requireHttps, std::size_t maximumLength = 8192); /// Reject address literals and well-known hostnames that are not publicly /// routable. DNS-backed validation lives in the external provider because /// only it opens outbound connections. [[nodiscard]] bool isObviouslyPrivateHost(std::string_view host) noexcept; /// Expand ${url} and ${env:NAME}. Environment variables are read without /// being copied into diagnostics; a missing variable reports only its name. [[nodiscard]] Result expandTemplate(std::string_view input, std::string_view url, bool encodeSubstitutions = false); } // namespace Echoion::Api::Plugin::ShortUrl