added strutil to verify urls
This commit is contained in:
@ -30,6 +30,7 @@ set(dependencies
|
||||
esp_system
|
||||
# esp_http_client
|
||||
esp_websocket_client
|
||||
nghttp
|
||||
tcp_transport
|
||||
|
||||
cpputils
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
// esp-idf includes
|
||||
#include <esp_log.h>
|
||||
#include <http_parser.h>
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <fmt/core.h>
|
||||
@ -57,4 +58,13 @@ void urldecode(char *dst, const char *src)
|
||||
*dst++ = '\0';
|
||||
}
|
||||
|
||||
tl::expected<void, std::string> urlverify(std::string_view str)
|
||||
{
|
||||
http_parser_url puri;
|
||||
http_parser_url_init(&puri);
|
||||
if (const auto result = http_parser_parse_url(str.data(), str.size(), 0, &puri); result != 0)
|
||||
return tl::make_unexpected(fmt::format("http_parser_parse_url() failed parsing the url with {}", result));
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace espcpputils
|
||||
|
@ -6,10 +6,15 @@
|
||||
// esp-idf includes
|
||||
#include <esp_sntp.h>
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <tl/expected.hpp>
|
||||
|
||||
namespace espcpputils {
|
||||
|
||||
std::string toString(sntp_sync_mode_t val);
|
||||
|
||||
void urldecode(char *dst, const char *src);
|
||||
|
||||
tl::expected<void, std::string> urlverify(std::string_view str);
|
||||
|
||||
} // namespace espcpputils
|
||||
|
Reference in New Issue
Block a user