Merge pull request #192 from MohamedV0/fix/windows-path-resolution

fix(windows): use path.posix for URL path resolution
This commit is contained in:
webadderall
2026-04-08 15:07:43 +10:00
committed by GitHub
2 changed files with 10 additions and 6 deletions
+10 -1
View File
@@ -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);
-5
View File
@@ -587,11 +587,6 @@ function loadPackagedEditorWindow(win: BrowserWindow) {
void win.loadFile(indexHtmlPath, { query });
};
if (process.platform === "win32") {
loadFromFile();
return;
}
if (!packagedRendererBaseUrl) {
loadFromFile();
return;