Skip to content

Commit

Permalink
epee: string_tools: keep full path in cut_off_extension
Browse files Browse the repository at this point in the history
  • Loading branch information
tobtoht committed Aug 14, 2024
1 parent c51ca53 commit a66539f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion contrib/epee/src/string_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ namespace string_tools
//----------------------------------------------------------------------------
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
Expand Down
7 changes: 7 additions & 0 deletions tests/unit_tests/epee_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1451,6 +1451,13 @@ TEST(StringTools, GetExtension)
EXPECT_EQ(std::string{"3"}, epee::string_tools::get_extension("1.2.3"));
}

TEST(StringTools, CutOffExtension)
{
EXPECT_EQ(std::string{}, epee::string_tools::get_extension(""));
EXPECT_EQ(std::string{"/home/user/Monero/wallets/wallet"}, epee::string_tools::get_extension("/home/user/Monero/wallets/wallet"));
EXPECT_EQ(std::string{"/home/user/Monero/wallets/wallet"}, epee::string_tools::get_extension("/home/user/Monero/wallets/wallet.keys"));
}

TEST(NetUtils, IPv4NetworkAddress)
{
static_assert(epee::net_utils::ipv4_network_address::get_type_id() == epee::net_utils::address_type::ipv4, "bad ipv4 type id");
Expand Down

0 comments on commit a66539f

Please sign in to comment.