commit 29ae3ee9e363b5b55854055eb355ff4c4794ab41
parent b35761cce2c5b3e3500504b78603bbbf4e589d7c
Author: Sebastian <sebastian@sebsite.pw>
Date: Sun, 13 Mar 2022 17:21:34 -0400
path: fix basename behavior
Prior to this commit, if the input was a single path component followed
by a slash, the output would also contain a slash. e.g. "foo/" would
return "foo/" instead of "foo".
Signed-off-by: Sebastian <sebastian@sebsite.pw>
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/path/names.ha b/path/names.ha
@@ -73,7 +73,7 @@ export fn basename(path: (str | *buffer)) const str = {
let b = strings::toutf8(trimmed);
let i = match (bytes::rindex(b, PATHSEP)) {
case void =>
- return path;
+ return trimmed;
case let z: size =>
yield if (z + 1 < len(b)) z + 1z else 0z;
};