Fix crash with empty fullname path
This commit is contained in:
@@ -7,11 +7,18 @@ public record FullName(string Path)
|
||||
var pathParts = Path.TrimEnd(Constants.SeparatorChar).Split(Constants.SeparatorChar);
|
||||
return pathParts.Length switch
|
||||
{
|
||||
> 1 => new(string.Join(Constants.SeparatorChar, pathParts.SkipLast(1))),
|
||||
> 1 => CreateSafe(string.Join(Constants.SeparatorChar, pathParts.SkipLast(1))),
|
||||
_ => null
|
||||
};
|
||||
}
|
||||
|
||||
public static FullName? CreateSafe(string? path)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(path))
|
||||
return null;
|
||||
return new(path);
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
=> Path.Split(Constants.SeparatorChar).Last();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user