uri: change clear into clear_fragment

This commit is contained in:
Danny Robson 2021-12-21 09:42:13 +10:00
parent 0912f68844
commit 5e05584708
2 changed files with 8 additions and 9 deletions

14
uri.cpp
View File

@ -128,18 +128,16 @@ uri::set (component c, std::string_view val)
//-----------------------------------------------------------------------------
void uri::clear (component const c)
void uri::clear_fragment ()
{
auto const offset = m_views[c].size ();
for (int i = c + 1; i < component::NUM_COMPONENTS; ++i)
m_views[i] -= offset;
if (!m_views[FRAGMENT])
return;
m_value.erase (
m_views[c].begin () - m_value.data (),
m_views[c].size ()
m_views[FRAGMENT].begin () - m_value.data (),
m_views[FRAGMENT].size ()
);
m_views[c] = nullptr;
m_views[FRAGMENT] = nullptr;
}

View File

@ -100,7 +100,8 @@ namespace cruft {
std::string_view query (void) const& { return get (QUERY); }
std::string_view fragment (void) const& { return get (FRAGMENT); }
void clear (component);
// void clear (component);
void clear_fragment (void);
auto components (void) const& noexcept { return m_views; }