Skip to content

Commit 821ba1c

Browse files
committed
Updates requested in the PR.
1 parent 9266de0 commit 821ba1c

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/util/file_util.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,13 @@ std::string fileutl_parse_name_in_pathname(std::string const &file_pathname)
201201
return file_pathname.substr(fileutl_parse_last_dir_pos(file_pathname));
202202
}
203203

204-
std::string fileutl_parse_extension_in_pathname(std::string const &pathname)
204+
std::string fileutl_parse_extension_in_pathname(const std::string &pathname)
205205
{
206206
const std::size_t idx=pathname.find_last_of('.');
207-
return idx==std::string::npos ? std::string("") : pathname.substr(idx);
207+
const std::size_t slash_idx=pathname.find_last_of('/');
208+
return
209+
idx==std::string::npos || (slash_idx!=std::string::npos && idx<slash_idx) ?
210+
std::string() : pathname.substr(idx);
208211
}
209212

210213
std::string fileutl_parse_path_in_pathname(std::string const &file_pathname)

src/util/file_util.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ uint64_t fileutl_file_size(std::string const &file_pathname);
3535

3636
std::string fileutl_parse_name_in_pathname(std::string const &file_pathname);
3737

38-
std::string fileutl_parse_extension_in_pathname(std::string const &pathname);
38+
std::string fileutl_parse_extension_in_pathname(const std::string &pathname);
3939

4040
std::string fileutl_parse_path_in_pathname(std::string const &file_pathname);
4141

0 commit comments

Comments
 (0)