mirror of
https://github.com/open-webui/computer.git
synced 2026-11-22 21:50:43 -05:00
18 lines
566 B
TypeScript
18 lines
566 B
TypeScript
export function isSupportedWorkspacePath(path: string | null | undefined): path is string {
|
|
if (!path) return false;
|
|
return (
|
|
path.startsWith('/') ||
|
|
path.startsWith('~/') ||
|
|
path.startsWith('~\\') ||
|
|
/^[a-zA-Z]:[\\/]/.test(path) ||
|
|
path.startsWith('\\\\')
|
|
);
|
|
}
|
|
|
|
export function getPathDisplayName(path: string | null | undefined, fallback = ''): string {
|
|
if (!path) return fallback;
|
|
const trimmed = path.replace(/[\\/]+$/, '');
|
|
const parts = trimmed.split(/[\\/]+/).filter(Boolean);
|
|
return parts[parts.length - 1] || trimmed || path || fallback;
|
|
}
|