summaryrefslogtreecommitdiffhomepage
path: root/packages/app/src/context/file/path.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/app/src/context/file/path.ts')
-rw-r--r--packages/app/src/context/file/path.ts11
1 files changed, 10 insertions, 1 deletions
diff --git a/packages/app/src/context/file/path.ts b/packages/app/src/context/file/path.ts
index 155f05aaf..e1d47c644 100644
--- a/packages/app/src/context/file/path.ts
+++ b/packages/app/src/context/file/path.ts
@@ -81,7 +81,16 @@ export function decodeFilePath(input: string) {
}
export function encodeFilePath(filepath: string): string {
- return filepath
+ // Normalize Windows paths: convert backslashes to forward slashes
+ let normalized = filepath.replace(/\\/g, "/")
+
+ // Handle Windows absolute paths (D:/path -> /D:/path for proper file:// URLs)
+ if (/^[A-Za-z]:/.test(normalized)) {
+ normalized = "/" + normalized
+ }
+
+ // Encode each path segment (preserving forward slashes as path separators)
+ return normalized
.split("/")
.map((segment) => encodeURIComponent(segment))
.join("/")