Skip to content

Commit

Permalink
Fixed the bug #5
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulkareem-siddiq committed Aug 18, 2021
1 parent c6ea2ac commit 8adfee9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
13 changes: 8 additions & 5 deletions src/SplitUri.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,14 @@ namespace siddiqsoft
// Parse the path into convenience vector of path elements
if (!pathSegment.empty()) parsePathElements(pathSegment, path);

queryPart = aEndpoint.substr(posQueryPart + 1,
posFragment != std::string::npos ? (posFragment) - (posQueryPart + 1)
: std::string::npos);
// Parse the query elements into a map
if (!queryPart.empty()) parseQueryElements(queryPart, query);
// Parse the query part if present
if (posQueryPart != std::string::npos) {
queryPart = aEndpoint.substr(posQueryPart + 1,
posFragment != std::string::npos ? (posFragment) - (posQueryPart + 1)
: std::string::npos);
// Parse the query elements into a map
if (!queryPart.empty()) parseQueryElements(queryPart, query);
}
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions tests/test_splituri_narrow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ TEST(helpers_splituri_narrow, test_1b)
auto uri = "https://YOURDBNAME.documents.azure.com:443/"_Uri;
EXPECT_EQ("YOURDBNAME.documents.azure.com", uri.authority.host);
EXPECT_EQ(443, uri.authority.port);

EXPECT_EQ("/", uri.urlPart);
EXPECT_EQ("", uri.queryPart);
EXPECT_EQ("https://YOURDBNAME.documents.azure.com:443/", std::string(uri));
}

Expand All @@ -77,7 +78,8 @@ TEST(helpers_splituri_narrow, test_1c)
auto uri = "https://YOURDBNAME.documents.azure.com:1443/"_Uri;
EXPECT_EQ("YOURDBNAME.documents.azure.com", uri.authority.host);
EXPECT_EQ(1443, uri.authority.port);

EXPECT_EQ("/", uri.urlPart);
EXPECT_EQ("", uri.queryPart);
EXPECT_EQ("https://YOURDBNAME.documents.azure.com:1443/", std::string(uri));
}

Expand Down
4 changes: 4 additions & 0 deletions tests/test_splituri_wide.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ TEST(helpers_splituri_wide, test_1b)
auto uri = L"https://YOURDBNAME.documents.azure.com:443/"_Uri;
EXPECT_EQ(L"YOURDBNAME.documents.azure.com", uri.authority.host);
EXPECT_EQ(443, uri.authority.port);
EXPECT_EQ(L"/", uri.urlPart);
EXPECT_EQ(L"", uri.queryPart);
EXPECT_EQ(L"https://YOURDBNAME.documents.azure.com:443/", std::wstring(uri));
}

Expand All @@ -78,6 +80,8 @@ TEST(helpers_splituri_wide, test_1c)
auto uri = L"https://YOURDBNAME.documents.azure.com:1443/"_Uri;
EXPECT_EQ(L"YOURDBNAME.documents.azure.com", uri.authority.host);
EXPECT_EQ(1443, uri.authority.port);
EXPECT_EQ(L"/", uri.urlPart);
EXPECT_EQ(L"", uri.queryPart);
EXPECT_EQ(L"https://YOURDBNAME.documents.azure.com:1443/", std::wstring(uri));
}

Expand Down

0 comments on commit 8adfee9

Please sign in to comment.