20 #include <ripple/basics/Slice.h>
21 #include <ripple/basics/StringUtilities.h>
22 #include <ripple/basics/ToString.h>
23 #include <ripple/basics/contract.h>
24 #include <ripple/beast/core/LexicalCast.h>
25 #include <ripple/beast/net/IPEndpoint.h>
26 #include <boost/algorithm/string.hpp>
27 #include <boost/regex.hpp>
50 static boost::regex reUrl(
53 "([[:alpha:]][-+.[:alpha:][:digit:]]*?):"
58 "(?:([^:@/]*?)(?::([^@/]*?))?@)?"
60 "([[:digit:]:]*[[:digit:]]|\\[[^]]+\\]|[^:/?#]*?)"
62 "(?::([[:digit:]]+))?"
66 boost::smatch smMatch;
71 if (!boost::regex_match(strUrl, smMatch, reUrl))
80 boost::algorithm::to_lower(pUrl.
scheme);
88 pUrl.
domain = result ? result->address().to_string() : domain;
92 pUrl.
port = beast::lexicalCast<std::uint16_t>(port);
101 pUrl.
path = smMatch[6];
126 if (domain.
size() < 4 || domain.
size() > 128)
133 static boost::regex
const re(
144 boost::regex_constants::optimize);
146 return boost::regex_match(domain, re);
T back_inserter(T... args)
std::string trim_whitespace(std::string str)
std::optional< std::uint16_t > port
std::optional< std::uint64_t > to_uint64(std::string const &s)
bool parseUrl(parsedURL &pUrl, std::string const &strUrl)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
bool lexicalCastChecked(Out &out, In in)
Intelligently convert from one type to another.
bool isProperlyFormedTomlDomain(std::string const &domain)
Determines if the given string looks like a TOML-file hosting domain.
static std::optional< Endpoint > from_string_checked(std::string const &s)
Create an Endpoint from a string.
std::string sqlBlobLiteral(Blob const &blob)
Format arbitrary binary data as an SQLite "blob literal".