Skip to content

Commit

Permalink
set empty path
Browse files Browse the repository at this point in the history
  • Loading branch information
alandefreitas committed Aug 19, 2022
1 parent d365586 commit a1f92f2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
6 changes: 4 additions & 2 deletions include/boost/url/detail/any_path_iter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ class enc_segs_iter
: it_(first)
, end_(last)
{
front = *first;
if (it_ != end_)
front = *first;
}

bool
Expand Down Expand Up @@ -241,7 +242,8 @@ class plain_segs_iter
: it_(first)
, end_(last)
{
front = *first;
if (first != last)
front = *first;
}

bool
Expand Down
42 changes: 24 additions & 18 deletions include/boost/url/impl/url_base.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -1079,21 +1079,25 @@ edit_segments(
// adjust capacity
reserve(size() + n - n0);

// start of output
auto dest = s_ + p0;
if (s_)
{
// start of output
auto dest = s_ + p0;

// move and size
std::memmove(
dest + n,
s_ + p1,
size() - p1);
u_.set_size(
id_path,
u_.len(id_path) -
(n0 - n));
u_.nseg_ = nseg1;
s_[size()] = '\0';
return dest;
// move and size
std::memmove(
dest + n,
s_ + p1,
size() - p1);
u_.set_size(
id_path,
u_.len(id_path) -
(n0 - n));
u_.nseg_ = nseg1;
s_[size()] = '\0';
return dest;
}
return s_;
}

// insert or replace [i0, i1)
Expand Down Expand Up @@ -1148,7 +1152,7 @@ edit_segments(
2 = "./"
3 = "/./"
This is malleable prefix that might need to
This is a malleable prefix that might need to
change according the URL scheme and authority.
*/
Expand Down Expand Up @@ -1193,8 +1197,10 @@ edit_segments(
':') != string_view::npos ||
it0.front.empty()))
{
BOOST_ASSERT(nseg > 0);
prefix = 2;
if (nseg > 0)
prefix = 2;
else
prefix = 0;
}
else if(
abs &&
Expand Down Expand Up @@ -1268,7 +1274,7 @@ edit_segments(
n += prefix + suffix;
auto dest = edit_segments(
i0, i1, n, nseg);
auto const last = dest + n;
char const *const last = dest + n;

/* Write all characters in the destination:
Expand Down
4 changes: 4 additions & 0 deletions test/unit/url.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,10 @@ class url_test
u.set_path(pct_encoded_view(s));
BOOST_TEST_EQ(u.string(), match);
};
check(
"",
"",
"");
check(
"",
"path/to/file.txt",
Expand Down

0 comments on commit a1f92f2

Please sign in to comment.