1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-16 07:22:43 +01:00

libstore: Introduce ParsedS3URL type

This systematizes the way our s3:// URLs are parsed in filetransfer.cc.
Yoinked out and refactored out of [1].

[1]: https://github.com/NixOS/nix/pull/13752

Co-authored-by: Bernardo Meurer Costa <beme@anthropic.com>
This commit is contained in:
Sergei Zimmerman 2025-08-19 23:21:36 +03:00
parent 5c0eff24d5
commit 69fcc2cfc1
No known key found for this signature in database
8 changed files with 212 additions and 28 deletions

View file

@ -30,7 +30,7 @@ struct ParsedURL
};
static Authority parse(std::string_view encodedAuthority);
bool operator==(const Authority & other) const = default;
auto operator<=>(const Authority & other) const = default;
std::string to_string() const;
friend std::ostream & operator<<(std::ostream & os, const Authority & self);
@ -81,7 +81,7 @@ struct ParsedURL
std::string to_string() const;
bool operator==(const ParsedURL & other) const noexcept = default;
auto operator<=>(const ParsedURL & other) const noexcept = default;
/**
* Remove `.` and `..` path elements.
@ -111,7 +111,7 @@ std::string encodeQuery(const StringMap & query);
*
* @throws BadURL
*/
ParsedURL parseURL(const std::string & url);
ParsedURL parseURL(std::string_view url);
/**
* Although thats not really standardized anywhere, an number of tools

View file

@ -108,10 +108,8 @@ static std::string percentEncodeCharSet(std::string_view s, auto charSet)
return res;
}
ParsedURL parseURL(const std::string & url)
ParsedURL parseURL(std::string_view url)
try {
auto unparsedView = url;
/* Account for several non-standard properties of nix urls (for back-compat):
* - Allow unescaped spaces ' ' and '"' characters in queries.
* - Allow '"', ' ' and '^' characters in the fragment component.