fix: replace Unix path assumptions with cross-platform isAbsolutePath

Windows daemon paths like C:\Users\... don't start with "/", breaking
the explorer sidebar, checkout status, terminals, and file attachments
when connected to a Windows daemon. Consolidate three private
isAbsolutePath implementations into a shared utility and use it
everywhere, with correct file URI conversion for Windows and UNC paths.
This commit is contained in:
Mohamed Boudra
2026-04-01 18:20:02 +07:00
parent d8d04c545e
commit c13972c835
10 changed files with 111 additions and 28 deletions
@@ -1,4 +1,5 @@
import { getDesktopHost } from "@/desktop/host";
import { isAbsolutePath } from "@/utils/path";
export type PickedImageSource = { kind: "file_uri"; uri: string } | { kind: "blob"; blob: Blob };
@@ -29,12 +30,8 @@ const IMAGE_FILE_EXTENSIONS = [
"svg",
];
function isAbsoluteWindowsPath(value: string): boolean {
return /^[a-zA-Z]:[\\/]/.test(value);
}
function shouldTreatAsFileUri(uri: string): boolean {
return uri.startsWith("file://") || uri.startsWith("/") || isAbsoluteWindowsPath(uri);
return uri.startsWith("file://") || isAbsolutePath(uri);
}
async function blobFromUri(uri: string): Promise<Blob> {