1 parent
639362fbf5
commit
bdd69f0aad
101 files changed
+22691
-531
No files matched your search
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
#include <Void/Data/Json.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <expected>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace Echoion::Plugins::ShortUrl
|
||||
{
|
||||
template <typename T> using Result = std::expected<T, std::string>;
|
||||
|
||||
[[nodiscard]] Result<Void::Json::Value>
|
||||
parseConfigObject(const char* config);
|
||||
[[nodiscard]] Result<std::string>
|
||||
requireString(const Void::Json::Value& object, std::string_view key);
|
||||
[[nodiscard]] Result<std::string>
|
||||
optionalString(const Void::Json::Value& object, std::string_view key,
|
||||
std::string_view fallback = {});
|
||||
[[nodiscard]] Result<bool> optionalBool(const Void::Json::Value& object,
|
||||
std::string_view key,
|
||||
bool fallback);
|
||||
[[nodiscard]] Result<std::int64_t>
|
||||
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<void>
|
||||
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<std::string>
|
||||
expandTemplate(std::string_view input, std::string_view url,
|
||||
bool encodeSubstitutions = false);
|
||||
|
||||
} // namespace Echoion::Plugins::ShortUrl
|
||||
Reference in new issue
Block a user