Skip to content

Commit 60923ec

Browse files
author
Shivendra Devadhe
committed
fix(cpp): handle npos in PathToDirectory for S3 URIs without query strings
1 parent d535a43 commit 60923ec

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

cpp/src/graphar/graph_info.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,8 +1103,10 @@ namespace {
11031103
static std::string PathToDirectory(const std::string& path) {
11041104
if (path.rfind("s3://", 0) == 0) {
11051105
size_t t = path.find_last_of('?');
1106-
std::string prefix = path.substr(0, t);
1107-
std::string suffix = path.substr(t);
1106+
1107+
std::string prefix = (t == std::string::npos) ? path : path.substr(0, t);
1108+
std::string suffix = (t == std::string::npos) ? "" : path.substr(t);
1109+
11081110
const size_t last_slash_idx = prefix.rfind('/');
11091111
if (std::string::npos != last_slash_idx) {
11101112
return prefix.substr(0, last_slash_idx + 1) + suffix;

0 commit comments

Comments
 (0)