mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-30 07:05:24 +00:00
feat: convert file manager into a plugin
This commit is contained in:
1 parent
b76da9ab52
commit
c85c1fdb86
259 files changed
+54155
-16791
No files matched your search
@@ -0,0 +1,26 @@
|
||||
export function normalizeRemoteDir(remotePath: string): string {
|
||||
const trimmed = remotePath.trim().replace(/\\/g, "/");
|
||||
if (!trimmed) return "/";
|
||||
const collapsed = trimmed.replace(/\/+/g, "/");
|
||||
const absolute = collapsed.startsWith("/") ? collapsed : `/${collapsed}`;
|
||||
if (absolute === "/") return "/";
|
||||
return absolute.replace(/\/+$/, "");
|
||||
}
|
||||
|
||||
export function joinRemotePath(basePath: string, childPath: string): string {
|
||||
const base = normalizeRemoteDir(basePath);
|
||||
const child = childPath.replace(/\\/g, "/").replace(/^\/+/, "");
|
||||
if (!child) return base;
|
||||
return base === "/" ? `/${child}` : `${base}/${child}`;
|
||||
}
|
||||
|
||||
export function hasSameHostTransferConflict(
|
||||
sourcePaths: string[],
|
||||
destinationDir: string,
|
||||
): boolean {
|
||||
const dest = normalizeRemoteDir(destinationDir);
|
||||
return sourcePaths.some((sourcePath) => {
|
||||
const source = normalizeRemoteDir(sourcePath);
|
||||
return dest === source || dest.startsWith(`${source}/`);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user