Boost logo

Boost :

From: Vinnie Falco (vinnie.falco_at_[hidden])
Date: 2021-10-14 01:19:31


On Wed, Oct 13, 2021 at 5:56 PM Gavin Lambert via Boost
<boost_at_[hidden]> wrote:
> part of the point of splitting paths into subcomponents
> is so that you don't have to think about the path separators.

Yeah.

> Some URI libraries will also explicitly iterate "" or "/" as the first
> component (by itself) to indicate the difference between absolute and
> relative URIs, although that could be indicated another way instead.

Currently this is done with

    // returns true if the path has a leading slash ('/')
    bool segments_view::is_absolute() const noexcept;

> In which case it might be best to render the absolute path as:
>...
> { "/", "path", "to", "file.txt" }

The problem comes with defining the mutation API. How does the user
put a URL into the state above using the segments container interface?

> I would imagine if u.segments() == { "my", "download", "folder", "" }
> before the push_back then after == { "my", "download", "folder",
> "index.htm" }.
>
> But that would be a special case only when the trailing component is empty.

I didn't even think of this, but that's yet another wrinkle.. lol

> The app would have to subsequently push_back("") if it was intending to
> leave a trailing final slash (or just push_back the next component if it
> wasn't finished yet). But either way it's the app's responsibilty to
> explicitly indicate whether the URL has a trailing slash or not; they
> are semantically different and a library cannot decide that for it.

Given the current container-like interface for modifiable encoded segments:

<https://master.url.cpp.al/url/ref/boost__urls__segments_encoded.html>

What might that API look like that allows the caller to indicate where
the slashes are?

Thanks


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk