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

libfetchers: Restore path separator ignoring behavior for indirect and git-archive flakerefs

Old versions of nix happily accepted a lot of weird flake references,
which we didn't have tests for, so this was accidentally broken in
c436b7a32a.

This patch restores previous behavior and adds a plethora of tests
to ensure we don't break this in the future.

These test cases are aligned with how 2.18/2.28 parsed flake references.
This commit is contained in:
Sergei Zimmerman 2025-08-30 14:40:56 +03:00
parent 511d885d60
commit a38ebdd511
No known key found for this signature in database
5 changed files with 184 additions and 2 deletions

View file

@ -1,6 +1,7 @@
#pragma once
///@file
#include <ranges>
#include <span>
#include "nix/util/error.hh"
@ -230,6 +231,20 @@ struct ParsedURL
* Remove `.` and `..` path segments.
*/
ParsedURL canonicalise();
/**
* Get a range of path segments (the substrings separated by '/' characters).
*
* @param skipEmpty Skip all empty path segments
*/
auto pathSegments(bool skipEmpty) const &
{
return std::views::filter(path, [skipEmpty](std::string_view segment) {
if (skipEmpty)
return !segment.empty();
return true;
});
}
};
std::ostream & operator<<(std::ostream & os, const ParsedURL & url);