Skip to content

Commit

Permalink
[FOLD] fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
alandefreitas committed Aug 24, 2022
1 parent ff7fa75 commit 0bcd820
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
9 changes: 6 additions & 3 deletions include/boost/url/impl/authority_view.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ int
authority_view::
compare(const authority_view& other) const noexcept
{
int comp = has_userinfo() - other.has_userinfo();
auto comp = static_cast<int>(has_userinfo()) -
static_cast<int>(other.has_userinfo());
if ( comp != 0 )
return comp;

Expand All @@ -281,7 +282,8 @@ compare(const authority_view& other) const noexcept
if ( comp != 0 )
return comp;

comp = has_password() - other.has_password();
comp = static_cast<int>(has_password()) -
static_cast<int>(other.has_password());
if ( comp != 0 )
return comp;

Expand All @@ -301,7 +303,8 @@ compare(const authority_view& other) const noexcept
if ( comp != 0 )
return comp;

comp = has_port() - other.has_port();
comp = static_cast<int>(has_port()) -
static_cast<int>(other.has_port());
if ( comp != 0 )
return comp;

Expand Down
2 changes: 1 addition & 1 deletion include/boost/url/impl/url.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ relative(
}
else if (*it1 == dotdot)
{
++it1;
if (it0 != begin0)
--it0;
++it1;
}
else
{
Expand Down
5 changes: 5 additions & 0 deletions test/unit/url.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2087,14 +2087,18 @@ class url_test
// relative URL / absolute paths
check("/a/path/to/somewhere/else", "/a/path/to/a", "../a");
check("/relative/sub/foo/sub/file", "/relative/path", "../../../path");
// resolve authority
check("http://google.com/baz", "http://example.org/world.html", "//example.org/world.html");
check("http://google.com/baz", "http://example.org/world.html?q#f", "//example.org/world.html?q#f");
check("http://google.com/baz", "http:/world.html", "/world.html");
check("http://www.example.com:8080/dir/file", "http://www.example.com:8080/dir/file", "");
check("http://www.example.com:8080/dir/file", "http://www.example.com:8080/dir/file?foo=bar#abcd", "?foo=bar#abcd");
// "." should be ignored
check("/a/path/././to/./somewhere/else", "/a/./path/./to/a", "../a");
// ".." should be normalized
check("/a/path/x/../to/y/../somewhere/else", "/b/../a/path/to/a", "../a");
// check("/../path/x/../to/y/../somewhere/else", "/a/../../path/to/a", "../a");
check("/a/path/to/somewhere/else", "/a/path/to/a/../b", "../b");
// same parent
check("/relative/file?some=query#hash", "/relative/path?blubber=1#hash1", "path?blubber=1#hash1");
// direct parent
Expand Down Expand Up @@ -2297,6 +2301,7 @@ class url_test
check("http://cppalliance.org/%2E%2E/./b/b/c/./../../g", "http://cppalliance.org/../a/g", +1);
check("http://[email protected]", "http://[email protected]", -1);
check("http://alice:[email protected]", "http://alice:[email protected]", 1);
check("http://[email protected]", "http://alice:[email protected]", -1);
check("http://alice:[email protected]", "http://alice:[email protected]", -1);
check("http://cppalliance.org", "http://cppalliance.org:81", -1);
check("http://cppalliance.org:80", "http://cppalliance.org:81", -1);
Expand Down
1 change: 0 additions & 1 deletion test/unit/url_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,6 @@ class url_view_test
testOutput();
testCases();
testRelativePart();

testParseOriginForm();
}
};
Expand Down

0 comments on commit 0bcd820

Please sign in to comment.