diff --git a/base/base_tests/file_name_utils_tests.cpp b/base/base_tests/file_name_utils_tests.cpp index 9fafc175ab..1d0b6c7381 100644 --- a/base/base_tests/file_name_utils_tests.cpp +++ b/base/base_tests/file_name_utils_tests.cpp @@ -81,6 +81,8 @@ UNIT_TEST(FilePath_Join) TEST_EQUAL("omim/strings.txt", base::JoinPath("omim/", "strings.txt"), ()); TEST_EQUAL("../../omim/strings.txt", base::JoinPath("..", "..", "omim", "strings.txt"), ()); TEST_EQUAL("../../omim/strings.txt", base::JoinPath("../", "..", "omim/", "strings.txt"), ()); + TEST_EQUAL("omim/strings.txt", base::JoinPath("", "omim/", "strings.txt"), ()); + TEST_EQUAL("omim/strings.txt", base::JoinPath("", "","omim/", "strings.txt"), ()); } #endif // OMIM_OS_WINDOWS diff --git a/base/file_name_utils.hpp b/base/file_name_utils.hpp index 71107f7407..1bfe7da57e 100644 --- a/base/file_name_utils.hpp +++ b/base/file_name_utils.hpp @@ -40,7 +40,12 @@ template std::string JoinPath(std::string const & folder, Args &&... args) { if (folder.empty()) - return {}; + { + if (sizeof...(args) == 0) + return {}; + else + return impl::JoinPath(std::forward(args)...); + } return AddSlashIfNeeded(folder) + impl::JoinPath(std::forward(args)...); } @@ -50,8 +55,6 @@ std::string JoinPath(std::string const & folder, Args &&... args) template std::string JoinPath(std::string const & dir, std::string const & fileOrDir, Args &&... args) { - ASSERT(!dir.empty(), ("JoinPath dir is empty")); - ASSERT(!fileOrDir.empty(), ("JoinPath fileOrDir is empty")); return impl::JoinPath(dir, fileOrDir, std::forward(args)...); } } // namespace base