Don't store fragment in FlakeRef

This commit is contained in:
Eelco Dolstra 2020-02-02 16:02:54 +01:00
parent 86748d3571
commit f83acbbfe3
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE

View file

@ -90,12 +90,11 @@ std::pair<FlakeRef, std::string> parseFlakeRefWithFragment(
.scheme = "flake",
.authority = "",
.path = match[1],
.fragment = percentDecode(std::string(match[6]))
};
return std::make_pair(
FlakeRef(inputFromURL(parsedURL), ""),
parsedURL.fragment);
percentDecode(std::string(match[6])));
}
/* Check if 'url' is a path (either absolute or relative to
@ -131,9 +130,10 @@ std::pair<FlakeRef, std::string> parseFlakeRefWithFragment(
.authority = "",
.path = flakeRoot,
.query = decodeQuery(match[2]),
.fragment = percentDecode(std::string(match[3]))
};
auto fragment = percentDecode(std::string(match[3]));
if (subdir != "") {
if (parsedURL.query.count("subdir"))
throw Error("flake URL '%s' has an inconsistent 'subdir' parameter", url);
@ -142,14 +142,16 @@ std::pair<FlakeRef, std::string> parseFlakeRefWithFragment(
return std::make_pair(
FlakeRef(inputFromURL(parsedURL), get(parsedURL.query, "subdir").value_or("")),
parsedURL.fragment);
fragment);
}
else {
auto parsedURL = parseURL(url);
std::string fragment;
std::swap(fragment, parsedURL.fragment);
return std::make_pair(
FlakeRef(inputFromURL(parsedURL), get(parsedURL.query, "subdir").value_or("")),
parsedURL.fragment);
fragment);
}
}