Skip to content

Commit

Permalink
[FOLD] refix set empty path
Browse files Browse the repository at this point in the history
  • Loading branch information
alandefreitas committed Sep 7, 2022
1 parent 2ca90ef commit 6bcce3d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions include/boost/url/impl/url.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ relative(
}
dest.remove_authority();

// Resolve path
// Resolve new path
dest.set_encoded_path({});

// 0. Get segments
auto segs0 = base.segments();
auto segs1 = href.segments();
Expand All @@ -211,8 +213,8 @@ relative(
auto const last1 = begin0 != end1 ? std::prev(end1) : end1;

// Function to advance the dotdot segments
pct_encoded_view dotdot("..");
pct_encoded_view dot(".");
decode_view dotdot("..");
decode_view dot(".");
auto consume_dots = [dotdot, dot](
segments_view::iterator& first,
segments_view::iterator last)
Expand Down Expand Up @@ -273,7 +275,6 @@ relative(
*it0 == *it1)
{
// Return empty path
dest.segments() = {};
if (href.has_query())
dest.set_encoded_query(href.encoded_query());
else
Expand All @@ -287,7 +288,6 @@ relative(

// 2. Append ".." for each segment left in base
segments_encoded segs = dest.encoded_segments();
segs = {};
if (it0 != end0)
{
dest.set_path_absolute(false);
Expand Down
3 changes: 2 additions & 1 deletion include/boost/url/impl/url_base.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -1957,7 +1957,8 @@ resize_segments(

// adjust capacity
std::size_t c = size() + n - n0;
if (c == 0)
if (s_ == nullptr &&
c == 0)
return nullptr;

reserve_impl(c, op);
Expand Down

0 comments on commit 6bcce3d

Please sign in to comment.