Skip to content

Commit 7cb69fa

Browse files
committed
epee: string_tools: keep full path in cut_off_extension
1 parent c7d4bf4 commit 7cb69fa

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
@@ -212,7 +212,7 @@ namespace string_tools
212212
//----------------------------------------------------------------------------
213213
std::string cut_off_extension(const std::string& str)
214214
{
215-
return boost::filesystem::path(str).stem().string();
215+
return boost::filesystem::path(str).replace_extension("").string();
216216
}
217217

218218
#ifdef _WIN32

tests/unit_tests/epee_utils.cpp

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

1438+
TEST(StringTools, CutOffExtension)
1439+
{
1440+
EXPECT_EQ(std::string{}, epee::string_tools::cut_off_extension(""));
1441+
EXPECT_EQ(std::string{"/home/user/Monero/wallets/wallet"}, epee::string_tools::cut_off_extension("/home/user/Monero/wallets/wallet"));
1442+
EXPECT_EQ(std::string{"/home/user/Monero/wallets/wallet"}, epee::string_tools::cut_off_extension("/home/user/Monero/wallets/wallet.keys"));
1443+
}
1444+
14381445
TEST(NetUtils, IPv4NetworkAddress)
14391446
{
14401447
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)