mirror of
https://github.com/falcosecurity/falco.git
synced 2025-08-13 11:55:50 +00:00
update(userspace/engine): url_is_unix_scheme() util is now is_unix_scheme(string_view)
Also no more custom `starts_with` utility function. Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
This commit is contained in:
parent
75c2275dac
commit
65e069a020
@ -68,19 +68,11 @@ void readfile(const std::string& filename, std::string& data)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool starts_with(const std::string& text, const std::string& prefix)
|
|
||||||
{
|
|
||||||
return prefix.empty() ||
|
|
||||||
(text.size() >= prefix.size() &&
|
|
||||||
std::memcmp(text.data(), prefix.data(), prefix.size()) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace network
|
namespace network
|
||||||
{
|
{
|
||||||
bool url_is_unix_scheme(const std::string& url)
|
bool is_unix_scheme(nonstd::string_view url)
|
||||||
{
|
{
|
||||||
return starts_with(url, UNIX_SCHEME);
|
return url.starts_with(UNIX_SCHEME);
|
||||||
}
|
}
|
||||||
} // namespace network
|
} // namespace network
|
||||||
} // namespace utils
|
} // namespace utils
|
||||||
|
@ -21,6 +21,7 @@ limitations under the License.
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <nonstd/string_view.hpp>
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
@ -33,11 +34,10 @@ namespace utils
|
|||||||
std::string wrap_text(const std::string& str, uint32_t initial_pos, uint32_t indent, uint32_t line_len);
|
std::string wrap_text(const std::string& str, uint32_t initial_pos, uint32_t indent, uint32_t line_len);
|
||||||
|
|
||||||
void readfile(const std::string& filename, std::string& data);
|
void readfile(const std::string& filename, std::string& data);
|
||||||
bool starts_with(const std::string& text, const std::string& prefix);
|
|
||||||
namespace network
|
namespace network
|
||||||
{
|
{
|
||||||
static const std::string UNIX_SCHEME{"unix://"};
|
static const std::string UNIX_SCHEME("unix://");
|
||||||
bool url_is_unix_scheme(const std::string& url);
|
bool is_unix_scheme(nonstd::string_view url);
|
||||||
} // namespace network
|
} // namespace network
|
||||||
} // namespace utils
|
} // namespace utils
|
||||||
} // namespace falco
|
} // namespace falco
|
||||||
|
Loading…
Reference in New Issue
Block a user