Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/http_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,11 @@ std::vector<std::string> http_utils::tokenize_url(

std::string http_utils::standardize_url(const std::string& url)
{
std::string n_url = string_utilities::regex_replace(url, "(\\/)+", "/");
std::string n_url = url;

std::string::iterator new_end = std::unique(n_url.begin(), n_url.end(), [](char a, char b) { return (a == b) && (a == '/'); });
n_url.erase(new_end, n_url.end());

std::string::size_type n_url_length = n_url.length();

std::string result;
Expand Down
4 changes: 4 additions & 0 deletions test/unit/http_utils_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ LT_BEGIN_AUTO_TEST(http_utils_suite, standardize_url)
url = "/abc/pqr", result = "";
result = http::http_utils::standardize_url(url);
LT_CHECK_EQ(result, "/abc/pqr");

url = "/abc//pqr", result = "";
result = http::http_utils::standardize_url(url);
LT_CHECK_EQ(result, "/abc/pqr");
LT_END_AUTO_TEST(standardize_url)

LT_BEGIN_AUTO_TEST(http_utils_suite, ip_to_str)
Expand Down