epee: string_tools: keep full path in cut_off_extension

This commit is contained in:
tobtoht 2024-08-14 19:45:55 +02:00
parent c7d4bf491e
commit 7cb69fa6bc
No known key found for this signature in database
GPG Key ID: E45B10DD027D2472
2 changed files with 8 additions and 1 deletions

View File

@ -212,7 +212,7 @@ namespace string_tools
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string cut_off_extension(const std::string& str) std::string cut_off_extension(const std::string& str)
{ {
return boost::filesystem::path(str).stem().string(); return boost::filesystem::path(str).replace_extension("").string();
} }
#ifdef _WIN32 #ifdef _WIN32

View File

@ -1435,6 +1435,13 @@ TEST(StringTools, GetExtension)
EXPECT_EQ(std::string{"3"}, epee::string_tools::get_extension("1.2.3")); EXPECT_EQ(std::string{"3"}, epee::string_tools::get_extension("1.2.3"));
} }
TEST(StringTools, CutOffExtension)
{
EXPECT_EQ(std::string{}, epee::string_tools::cut_off_extension(""));
EXPECT_EQ(std::string{"/home/user/Monero/wallets/wallet"}, epee::string_tools::cut_off_extension("/home/user/Monero/wallets/wallet"));
EXPECT_EQ(std::string{"/home/user/Monero/wallets/wallet"}, epee::string_tools::cut_off_extension("/home/user/Monero/wallets/wallet.keys"));
}
TEST(NetUtils, IPv4NetworkAddress) TEST(NetUtils, IPv4NetworkAddress)
{ {
static_assert(epee::net_utils::ipv4_network_address::get_type_id() == epee::net_utils::address_type::ipv4, "bad ipv4 type id"); static_assert(epee::net_utils::ipv4_network_address::get_type_id() == epee::net_utils::address_type::ipv4, "bad ipv4 type id");