Skip to content

Commit 39d7630

Browse files
committed
Fixed some compilation errors on MSVC; Added tests for equality when the URI strings are invalid or empty.
1 parent 275ed5d commit 39d7630

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

libs/network/src/uri/normalize.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ uri::string_type normalize_path(const uri::const_range_type &path) {
3030

3131
// remove single dot segments
3232
remove_erase_if(path_segments, [] (const uri::string_type &s) {
33-
return equal(s, as_literal("."));
33+
return equal(s, boost::as_literal("."));
3434
});
3535

3636
// remove double dot segments
3737
std::vector<std::string> normalized_segments;
3838
auto depth = 0;
3939
for_each(path_segments, [&normalized_segments, &depth] (const uri::string_type &s) {
4040
assert(depth >= 0);
41-
if (equal(s, as_literal(".."))) {
41+
if (equal(s, boost::as_literal(".."))) {
4242
normalized_segments.pop_back();
4343
}
4444
else {

libs/network/src/uri/uri.cpp

+11-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@
1010
#include <boost/algorithm/string/predicate.hpp>
1111
#include <map>
1212

13-
#include <iterator>
14-
#include <iostream>
15-
1613
namespace network {
1714
bool operator == (const uri &lhs, const uri &rhs) {
15+
16+
// if both URIs are empty, then we should define them as equal even though they're still invalid.
17+
if (boost::empty(lhs) && boost::empty(rhs)) {
18+
return true;
19+
}
20+
21+
if (!valid(lhs) || !valid(rhs)) {
22+
return false;
23+
}
24+
1825
// the scheme can be compared insensitive to case
1926
bool equal = boost::iequals(lhs.scheme_range(), rhs.scheme_range());
2027
if (equal) {
@@ -46,7 +53,7 @@ bool operator == (const uri &lhs, const uri &rhs) {
4653
}
4754

4855
if (equal) {
49-
// TODO: test normalized paths
56+
// test normalized paths
5057
equal = boost::iequals(normalize_path(lhs.path_range()), normalize_path(rhs.path_range()));
5158
}
5259

0 commit comments

Comments
 (0)