mirror of
https://github.com/boostorg/url.git
synced 2026-02-14 01:02:17 +00:00
Add set_path_absolute
This commit is contained in:
@@ -1139,6 +1139,14 @@ edit_segments(
|
||||
detail::any_path_iter&& it1,
|
||||
int abs_hint)
|
||||
{
|
||||
if(abs_hint == -1)
|
||||
{
|
||||
if(get(id_path).starts_with('/'))
|
||||
abs_hint = 1;
|
||||
else
|
||||
abs_hint = 0;
|
||||
}
|
||||
|
||||
// measure
|
||||
error_code ec;
|
||||
std::size_t n = 0;
|
||||
@@ -1254,6 +1262,46 @@ edit_segments(
|
||||
|
||||
//------------------------------------------------
|
||||
|
||||
bool
|
||||
url::
|
||||
set_path_absolute(bool absolute)
|
||||
{
|
||||
if(len(id_path) == 0)
|
||||
{
|
||||
if(! absolute)
|
||||
return true;
|
||||
auto dest = resize_impl(
|
||||
id_path, 1);
|
||||
*dest = '/';
|
||||
// VFALCO Update table
|
||||
return true;
|
||||
}
|
||||
|
||||
if(s_[offset(id_path)] == '/')
|
||||
{
|
||||
if(absolute)
|
||||
return true;
|
||||
if( has_authority() &&
|
||||
len(id_path) > 1)
|
||||
return false;
|
||||
auto n = len(id_port);
|
||||
split(id_port, n + 1);
|
||||
resize_impl(id_port, n);
|
||||
// VFALCO Update table
|
||||
return true;
|
||||
}
|
||||
|
||||
if(! absolute)
|
||||
return true;
|
||||
auto n = len(id_port);
|
||||
auto dest = resize_impl(
|
||||
id_port, n + 1) + n;
|
||||
split(id_port, n);
|
||||
*dest = '/';
|
||||
// VFALCO Update table
|
||||
return true;
|
||||
}
|
||||
|
||||
url&
|
||||
url::
|
||||
set_encoded_path(
|
||||
|
||||
@@ -75,7 +75,7 @@ split(
|
||||
std::size_t n) noexcept
|
||||
{
|
||||
BOOST_ASSERT(id < id_end - 1);
|
||||
BOOST_ASSERT(n <= len(id));
|
||||
//BOOST_ASSERT(n <= len(id));
|
||||
offset_[id + 1] = offset(id) + n;
|
||||
}
|
||||
|
||||
|
||||
@@ -898,6 +898,17 @@ private:
|
||||
int abs_hint = -1);
|
||||
public:
|
||||
|
||||
/** Set whether the path is absolute.
|
||||
|
||||
This modifies the path as needed to
|
||||
make it absolute or relative.
|
||||
|
||||
@return true on success.
|
||||
*/
|
||||
BOOST_URL_DECL
|
||||
bool
|
||||
set_path_absolute(bool absolute);
|
||||
|
||||
/** Set the path.
|
||||
|
||||
This function validates the given percent-encoded
|
||||
|
||||
Reference in New Issue
Block a user