Skip to content

Commit 89ad8ac

Browse files
committed
epee: string_tools: keep full path in cut_off_extension
1 parent c51ca53 commit 89ad8ac

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

contrib/epee/src/string_tools.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ namespace string_tools
189189
//----------------------------------------------------------------------------
190190
std::string cut_off_extension(const std::string& str)
191191
{
192-
return boost::filesystem::path(str).stem().string();
192+
return boost::filesystem::path(str).replace_extension("").string();
193193
}
194194

195195
#ifdef _WIN32

tests/unit_tests/epee_utils.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,13 @@ TEST(StringTools, GetExtension)
14511451
EXPECT_EQ(std::string{"3"}, epee::string_tools::get_extension("1.2.3"));
14521452
}
14531453

1454+
TEST(StringTools, CutOffExtension)
1455+
{
1456+
EXPECT_EQ(std::string{}, epee::string_tools::cut_off_extension(""));
1457+
EXPECT_EQ(std::string{"/home/user/Monero/wallets/wallet"}, epee::string_tools::cut_off_extension("/home/user/Monero/wallets/wallet"));
1458+
EXPECT_EQ(std::string{"/home/user/Monero/wallets/wallet"}, epee::string_tools::cut_off_extension("/home/user/Monero/wallets/wallet.keys"));
1459+
}
1460+
14541461
TEST(NetUtils, IPv4NetworkAddress)
14551462
{
14561463
static_assert(epee::net_utils::ipv4_network_address::get_type_id() == epee::net_utils::address_type::ipv4, "bad ipv4 type id");

0 commit comments

Comments
 (0)