1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 10:41:16 +02:00

ParsedURL: Remove base field

This commit is contained in:
Eelco Dolstra 2025-01-07 14:52:00 +01:00
parent f705ce7f9a
commit 4077aa43a8
6 changed files with 2 additions and 20 deletions

View file

@ -426,7 +426,7 @@ struct GitInputScheme : InputScheme
auto url = parseURL(getStrAttr(input.attrs, "url")); auto url = parseURL(getStrAttr(input.attrs, "url"));
bool isBareRepository = url.scheme == "file" && !pathExists(url.path + "/.git"); bool isBareRepository = url.scheme == "file" && !pathExists(url.path + "/.git");
repoInfo.isLocal = url.scheme == "file" && !forceHttp && !isBareRepository; repoInfo.isLocal = url.scheme == "file" && !forceHttp && !isBareRepository;
repoInfo.url = repoInfo.isLocal ? url.path : url.base; repoInfo.url = repoInfo.isLocal ? url.path : url.to_string();
// If this is a local directory and no ref or revision is // If this is a local directory and no ref or revision is
// given, then allow the use of an unclean working tree. // given, then allow the use of an unclean working tree.

View file

@ -161,7 +161,7 @@ struct MercurialInputScheme : InputScheme
{ {
auto url = parseURL(getStrAttr(input.attrs, "url")); auto url = parseURL(getStrAttr(input.attrs, "url"));
bool isLocal = url.scheme == "file"; bool isLocal = url.scheme == "file";
return {isLocal, isLocal ? url.path : url.base}; return {isLocal, isLocal ? url.path : url.to_string()};
} }
StorePath fetchToStore(ref<Store> store, Input & input) const StorePath fetchToStore(ref<Store> store, Input & input) const

View file

@ -159,10 +159,7 @@ std::pair<FlakeRef, std::string> parsePathFlakeRefWithFragment(
while (flakeRoot != "/") { while (flakeRoot != "/") {
if (pathExists(flakeRoot + "/.git")) { if (pathExists(flakeRoot + "/.git")) {
auto base = std::string("git+file://") + flakeRoot;
auto parsedURL = ParsedURL{ auto parsedURL = ParsedURL{
.base = base,
.scheme = "git+file", .scheme = "git+file",
.authority = "", .authority = "",
.path = flakeRoot, .path = flakeRoot,
@ -219,7 +216,6 @@ static std::optional<std::pair<FlakeRef, std::string>> parseFlakeIdRef(
if (std::regex_match(url, match, flakeRegex)) { if (std::regex_match(url, match, flakeRegex)) {
auto parsedURL = ParsedURL{ auto parsedURL = ParsedURL{
.base = "flake:" + match.str(1),
.scheme = "flake", .scheme = "flake",
.authority = "", .authority = "",
.path = match[1], .path = match[1],

View file

@ -25,7 +25,6 @@ namespace nix {
auto parsed = parseURL(s); auto parsed = parseURL(s);
ParsedURL expected { ParsedURL expected {
.base = "http://www.example.org/file.tar.gz",
.scheme = "http", .scheme = "http",
.authority = "www.example.org", .authority = "www.example.org",
.path = "/file.tar.gz", .path = "/file.tar.gz",
@ -41,7 +40,6 @@ namespace nix {
auto parsed = parseURL(s); auto parsed = parseURL(s);
ParsedURL expected { ParsedURL expected {
.base = "https://www.example.org/file.tar.gz",
.scheme = "https", .scheme = "https",
.authority = "www.example.org", .authority = "www.example.org",
.path = "/file.tar.gz", .path = "/file.tar.gz",
@ -57,7 +55,6 @@ namespace nix {
auto parsed = parseURL(s); auto parsed = parseURL(s);
ParsedURL expected { ParsedURL expected {
.base = "https://www.example.org/file.tar.gz",
.scheme = "https", .scheme = "https",
.authority = "www.example.org", .authority = "www.example.org",
.path = "/file.tar.gz", .path = "/file.tar.gz",
@ -73,7 +70,6 @@ namespace nix {
auto parsed = parseURL(s); auto parsed = parseURL(s);
ParsedURL expected { ParsedURL expected {
.base = "http://www.example.org/file.tar.gz",
.scheme = "http", .scheme = "http",
.authority = "www.example.org", .authority = "www.example.org",
.path = "/file.tar.gz", .path = "/file.tar.gz",
@ -89,7 +85,6 @@ namespace nix {
auto parsed = parseURL(s); auto parsed = parseURL(s);
ParsedURL expected { ParsedURL expected {
.base = "https://www.example.org/video.mp4",
.scheme = "file+https", .scheme = "file+https",
.authority = "www.example.org", .authority = "www.example.org",
.path = "/video.mp4", .path = "/video.mp4",
@ -110,7 +105,6 @@ namespace nix {
auto parsed = parseURL(s); auto parsed = parseURL(s);
ParsedURL expected { ParsedURL expected {
.base = "https://127.0.0.1:8080/file.tar.gz",
.scheme = "http", .scheme = "http",
.authority = "127.0.0.1:8080", .authority = "127.0.0.1:8080",
.path = "/file.tar.gz", .path = "/file.tar.gz",
@ -126,7 +120,6 @@ namespace nix {
auto parsed = parseURL(s); auto parsed = parseURL(s);
ParsedURL expected { ParsedURL expected {
.base = "http://[fe80::818c:da4d:8975:415c\%enp0s25]:8080",
.scheme = "http", .scheme = "http",
.authority = "[fe80::818c:da4d:8975:415c\%enp0s25]:8080", .authority = "[fe80::818c:da4d:8975:415c\%enp0s25]:8080",
.path = "", .path = "",
@ -143,7 +136,6 @@ namespace nix {
auto parsed = parseURL(s); auto parsed = parseURL(s);
ParsedURL expected { ParsedURL expected {
.base = "http://[2a02:8071:8192:c100:311d:192d:81ac:11ea]:8080",
.scheme = "http", .scheme = "http",
.authority = "[2a02:8071:8192:c100:311d:192d:81ac:11ea]:8080", .authority = "[2a02:8071:8192:c100:311d:192d:81ac:11ea]:8080",
.path = "", .path = "",
@ -166,7 +158,6 @@ namespace nix {
auto parsed = parseURL(s); auto parsed = parseURL(s);
ParsedURL expected { ParsedURL expected {
.base = "http://user:pass@www.example.org/file.tar.gz",
.scheme = "http", .scheme = "http",
.authority = "user:pass@www.example.org:8080", .authority = "user:pass@www.example.org:8080",
.path = "/file.tar.gz", .path = "/file.tar.gz",
@ -183,7 +174,6 @@ namespace nix {
auto parsed = parseURL(s); auto parsed = parseURL(s);
ParsedURL expected { ParsedURL expected {
.base = "",
.scheme = "file", .scheme = "file",
.authority = "", .authority = "",
.path = "/none/of//your/business", .path = "/none/of//your/business",
@ -207,7 +197,6 @@ namespace nix {
auto parsed = parseURL(s); auto parsed = parseURL(s);
ParsedURL expected { ParsedURL expected {
.base = "ftp://ftp.nixos.org/downloads/nixos.iso",
.scheme = "ftp", .scheme = "ftp",
.authority = "ftp.nixos.org", .authority = "ftp.nixos.org",
.path = "/downloads/nixos.iso", .path = "/downloads/nixos.iso",

View file

@ -40,7 +40,6 @@ ParsedURL parseURL(const std::string & url)
path = "/"; path = "/";
return ParsedURL{ return ParsedURL{
.base = base,
.scheme = scheme, .scheme = scheme,
.authority = authority, .authority = authority,
.path = percentDecode(path), .path = percentDecode(path),

View file

@ -7,8 +7,6 @@ namespace nix {
struct ParsedURL struct ParsedURL
{ {
/// URL without query/fragment
std::string base; // FIXME: remove
std::string scheme; std::string scheme;
std::optional<std::string> authority; std::optional<std::string> authority;
std::string path; std::string path;