fix: 在混合使用 / 和 \ 时路径裁剪有误
This commit is contained in:
1 parent
883b912104
commit
5ee6f88cde
4 files changed
+129
-31
No files matched your search
@@ -94,10 +94,8 @@ public static class PathUtils {
|
||||
public static string RemoveLastPart(string path) {
|
||||
if (path!.Contains("://")) { // 网络路径
|
||||
path = PathUtils.RemoveSlashSuffix(path.BeforeFirst("#").BeforeFirst("?")); // 去除参数
|
||||
return PathUtils.RemoveSlashSuffix(path).BeforeLast("/");
|
||||
} else { // 文件路径
|
||||
return PathUtils.RemoveSlashSuffix(path!).BeforeLast("\\");
|
||||
}
|
||||
return PathUtils.RemoveSlashSuffix(path!).BeforeLastOfAny([@"\", "/"]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -111,10 +109,10 @@ public static class PathUtils {
|
||||
public static string GetLastPart(string path) {
|
||||
if (path!.Contains("://")) { // 网络路径
|
||||
path = PathUtils.RemoveSlashSuffix(path.BeforeFirst("#").BeforeFirst("?")); // 去除参数
|
||||
return path.AfterLast("/");
|
||||
} else { // 文件路径
|
||||
return PathUtils.RemoveSlashSuffix(path).AfterLast("\\");
|
||||
path = PathUtils.RemoveSlashSuffix(path);
|
||||
}
|
||||
return path.AfterLastOfAny([@"\", "/"]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in new issue
Block a user