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

Merge pull request #10306 from hercules-ci/baseNameOf

Test and document `builtins.baseNameOf`, improve internal `baseNameOf()`
This commit is contained in:
Théophane Hufschmitt 2024-03-26 09:59:27 +01:00 committed by GitHub
commit 1394d4e9c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 76 additions and 6 deletions

View file

@ -128,7 +128,7 @@ std::string_view baseNameOf(std::string_view path)
return "";
auto last = path.size() - 1;
if (path[last] == '/' && last > 0)
while (last > 0 && path[last] == '/')
last -= 1;
auto pos = path.rfind('/', last);