mirror of
https://github.com/webadderallorg/Recordly.git
synced 2026-09-27 08:15:42 +00:00
Merge pull request #192 from MohamedV0/fix/windows-path-resolution
fix(windows): use path.posix for URL path resolution
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -587,11 +587,6 @@ function loadPackagedEditorWindow(win: BrowserWindow) {
|
||||
void win.loadFile(indexHtmlPath, { query });
|
||||
};
|
||||
|
||||
if (process.platform === "win32") {
|
||||
loadFromFile();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!packagedRendererBaseUrl) {
|
||||
loadFromFile();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user