Merge pull request #636 from Zagrios/bugfix/unable-to-load-bsm-files-if-path-to-bsm-contains-url-special-chars

[bugfix] Unable to load bsm's files if path to bsm contain url special chars

(cherry picked from commit 6666685c43)
This commit is contained in:
MathieuG-P
2024-11-04 16:41:29 +01:00
parent 2e6224825f
commit da40448ca1
+10 -12
View File
@@ -1,17 +1,15 @@
/* eslint import/prefer-default-export: off, import/no-mutable-exports: off */
import { URL } from "url";
import { pathToFileURL, URL } from "url";
import path from "path";
export let resolveHtmlPath: (htmlFileName: string) => string;
if (process.env.NODE_ENV === "development") {
const port = process.env.PORT || 1212;
resolveHtmlPath = (htmlFileName: string) => {
export function resolveHtmlPath (htmlFileName: string) {
if (process.env.NODE_ENV === "development") {
const port = process.env.PORT || 1212;
const url = new URL(`http://localhost:${port}/${htmlFileName}`);
return url.toString();
};
} else {
resolveHtmlPath = (htmlFileName: string) => {
return `file://${path.resolve(__dirname, "../renderer/", htmlFileName)}`;
};
}
}
const filePath = path.resolve(__dirname, "..", "renderer", htmlFileName);
return pathToFileURL(filePath).toString();
};