1
0
mirror of https://github.com/upscayl/upscayl.git synced 2024-09-24 03:18:28 +02:00

fixed windows pathname errors

This commit is contained in:
TGS963 2023-04-23 13:26:49 +05:30
parent 9ebc802718
commit 55bc31efc1

View File

@ -32,6 +32,10 @@ import commands from "./commands";
log.initialize({ preload: true }); log.initialize({ preload: true });
function escapeRegExp(string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
}
// Prepare the renderer once the app is ready // Prepare the renderer once the app is ready
let mainWindow: BrowserWindow; let mainWindow: BrowserWindow;
app.on("ready", async () => { app.on("ready", async () => {
@ -160,7 +164,7 @@ ipcMain.handle(commands.SELECT_FILE, async () => {
} else { } else {
logit("Selected File Path: ", filePaths[0]); logit("Selected File Path: ", filePaths[0]);
imagePath = filePaths[0]; imagePath = filePaths[0].replace(new RegExp(escapeRegExp('\\'), 'g'), '\\\\');
mainWindow.webContents mainWindow.webContents
.executeJavaScript( .executeJavaScript(
`localStorage.setItem("lastImagePath", "${imagePath}");`, `localStorage.setItem("lastImagePath", "${imagePath}");`,
@ -214,7 +218,7 @@ ipcMain.handle(commands.SELECT_FOLDER, async (event, message) => {
return null; return null;
} else { } else {
logit("Selected Folder Path: ", folderPaths[0]); logit("Selected Folder Path: ", folderPaths[0]);
folderPath = folderPaths[0]; folderPath = folderPaths[0].replace(new RegExp(escapeRegExp('\\'), 'g'), '\\\\');;
mainWindow.webContents mainWindow.webContents
.executeJavaScript( .executeJavaScript(
`localStorage.setItem("lastFolderPath", "${folderPath}");`, `localStorage.setItem("lastFolderPath", "${folderPath}");`,