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 Aug 26, 2022
1 parent 32c33c1 commit 579deee
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 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 @@ -192,7 +192,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 @@ -208,8 +210,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 @@ -270,7 +272,6 @@ relative(
*it0 == *it1)
{
// Return empty path
dest.segments() = {};
if (href.has_query())
dest.set_encoded_query(href.encoded_query());
else
Expand All @@ -284,7 +285,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 @@ -1081,7 +1081,8 @@ edit_segments(

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

reserve(c);
Expand Down
2 changes: 1 addition & 1 deletion include/boost/url/url_view_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1434,7 +1434,7 @@ class BOOST_SYMBOL_VISIBLE
{
decode_opts opt;
opt.plus_to_space = false;
return pct_encoded_view(encoded_path());
return decode_view(encoded_path());
}

/** Return the path segments
Expand Down

0 comments on commit 579deee

Please sign in to comment.