mirror of
https://github.com/NixOS/nix.git
synced 2025-11-11 13:06:01 +01:00
Merge branch 'master' into debug-exploratory-PR
This commit is contained in:
commit
9a5ea6c359
34 changed files with 429 additions and 85 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#include "url.hh"
|
||||
#include "url-parts.hh"
|
||||
#include "util.hh"
|
||||
#include "split.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
|
|
@ -136,4 +137,21 @@ bool ParsedURL::operator ==(const ParsedURL & other) const
|
|||
&& fragment == other.fragment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a URL scheme of the form '(applicationScheme\+)?transportScheme'
|
||||
* into a tuple '(applicationScheme, transportScheme)'
|
||||
*
|
||||
* > parseUrlScheme("http") == ParsedUrlScheme{ {}, "http"}
|
||||
* > parseUrlScheme("tarball+http") == ParsedUrlScheme{ {"tarball"}, "http"}
|
||||
*/
|
||||
ParsedUrlScheme parseUrlScheme(std::string_view scheme)
|
||||
{
|
||||
auto application = splitPrefixTo(scheme, '+');
|
||||
auto transport = scheme;
|
||||
return ParsedUrlScheme {
|
||||
.application = application,
|
||||
.transport = transport,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,4 +27,19 @@ std::map<std::string, std::string> decodeQuery(const std::string & query);
|
|||
|
||||
ParsedURL parseURL(const std::string & url);
|
||||
|
||||
/*
|
||||
* Although that’s not really standardized anywhere, an number of tools
|
||||
* use a scheme of the form 'x+y' in urls, where y is the “transport layer”
|
||||
* scheme, and x is the “application layer” scheme.
|
||||
*
|
||||
* For example git uses `git+https` to designate remotes using a Git
|
||||
* protocol over http.
|
||||
*/
|
||||
struct ParsedUrlScheme {
|
||||
std::optional<std::string_view> application;
|
||||
std::string_view transport;
|
||||
};
|
||||
|
||||
ParsedUrlScheme parseUrlScheme(std::string_view scheme);
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue