![]() |
Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
|
#include <url.hh>
Public Types | |
| using | Raw = std::variant<std::string, ParsedURL> |
Public Member Functions | |
| VerbatimURL (std::string_view s) | |
| VerbatimURL (std::string s) | |
| VerbatimURL (ParsedURL url) | |
| std::string | to_string () const |
| const ParsedURL | parsed () const |
| std::string_view | scheme () const & |
| std::optional< std::string > | lastPathSegment () const |
Public Attributes | |
| Raw | raw |
Either a ParsedURL or a verbatim string. This is necessary because in certain cases URI must be passed verbatim (e.g. in builtin fetchers), since those are specified by the user. In those cases normalizations performed by the ParsedURL might be surprising and undesirable, since Nix must be a universal client that has to work with various broken services that might interpret URLs in quirky and non-standard ways.
One of those examples is space-as-plus encoding that is very widespread, but it's not strictly RFC3986 compliant. We must preserve that information verbatim.
Though we perform parsing and validation for internal needs.
| std::optional< std::string > nix::VerbatimURL::lastPathSegment | ( | ) | const |
Get the last non-empty path segment from the URL.
This is useful for extracting filenames from URLs. For example, "https://example.com/path/to/file.txt?query=value" returns "file.txt".
|
inline |
Get the encoded URL (if specified) verbatim or encode the parsed URL.