1#include <xrpl/basics/Blob.h>
2#include <xrpl/basics/StringUtilities.h>
3#include <xrpl/beast/core/LexicalCast.h>
4#include <xrpl/beast/net/IPEndpoint.h>
6#include <boost/algorithm/hex.hpp>
7#include <boost/algorithm/string/case_conv.hpp>
8#include <boost/algorithm/string/trim.hpp>
9#include <boost/regex/v5/regbase.hpp>
10#include <boost/regex/v5/regex.hpp>
11#include <boost/regex/v5/regex_fwd.hpp>
12#include <boost/regex/v5/regex_match.hpp>
40 static boost::regex reUrl(
43 "([[:alpha:]][-+.[:alpha:][:digit:]]*?):"
48 "(?:([^:@/]*?)(?::([^@/]*?))?@)?"
50 "([[:digit:]:]*[[:digit:]]|\\[[^]]+\\]|[^:/?#]*?)"
52 "(?::([[:digit:]]+))?"
56 boost::smatch smMatch;
61 if (!boost::regex_match(strUrl, smMatch, reUrl))
70 boost::algorithm::to_lower(pUrl.
scheme);
78 pUrl.
domain = result ? result->address().to_string() : domain;
82 pUrl.
port = beast::lexicalCast<std::uint16_t>(port);
91 pUrl.
path = smMatch[6];
116 if (domain.
size() < 4 || domain.
size() > 128)
123 static boost::regex
const re(
134 boost::regex_constants::optimize);
136 return boost::regex_match(domain.
begin(), domain.
end(), re);
T back_inserter(T... args)
static std::optional< Endpoint > from_string_checked(std::string const &s)
Create an Endpoint from a string.
bool lexicalCastChecked(Out &out, In in)
Intelligently convert from one type to another.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::string trim_whitespace(std::string str)
std::optional< std::uint64_t > to_uint64(std::string const &s)
bool parseUrl(parsedURL &pUrl, std::string const &strUrl)
std::string sqlBlobLiteral(Blob const &blob)
Format arbitrary binary data as an SQLite "blob literal".
bool isProperlyFormedTomlDomain(std::string_view domain)
Determines if the given string looks like a TOML-file hosting domain.
std::optional< std::uint16_t > port