diff --git a/electron/rendererServer.ts b/electron/rendererServer.ts index 881430c5..a8491b73 100644 --- a/electron/rendererServer.ts +++ b/electron/rendererServer.ts @@ -30,7 +30,16 @@ function getContentType(filePath: string): string { function resolveRequestedFilePath(rootDir: string, requestPathname: string): string | null { const trimmedPathname = requestPathname === "/" ? "/index.html" : requestPathname; - const relativePath = path.normalize(decodeURIComponent(trimmedPathname)).replace(/^\/+/, ""); + + // path.normalize() on Windows converts / to \, making the leading-slash + // regex fail and causing path.resolve to escape to the drive root. + const normalizedPosix = path.posix.normalize(decodeURIComponent(trimmedPathname)); + const relativePath = normalizedPosix.replace(/^\/+/, ""); + + if (!relativePath) { + return null; + } + const resolvedRootDir = path.resolve(rootDir); const resolvedFilePath = path.resolve(resolvedRootDir, relativePath); diff --git a/electron/windows.ts b/electron/windows.ts index c68b3c08..70116941 100644 --- a/electron/windows.ts +++ b/electron/windows.ts @@ -587,11 +587,6 @@ function loadPackagedEditorWindow(win: BrowserWindow) { void win.loadFile(indexHtmlPath, { query }); }; - if (process.platform === "win32") { - loadFromFile(); - return; - } - if (!packagedRendererBaseUrl) { loadFromFile(); return;