Skip to content

Commit

Permalink
electron: Fix path comparison for exit confirmation (#10597)
Browse files Browse the repository at this point in the history
  • Loading branch information
msujew authored Jan 10, 2022
1 parent e0359d4 commit 52a6529
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/core/src/electron-main/electron-main-application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,14 @@ export class ElectronMainApplication {

protected async handleStopRequest(electronWindow: BrowserWindow, onSafeCallback: () => unknown, reason: StopReason): Promise<void> {
// Only confirm close to windows that have loaded our front end.
const safeToClose = !electronWindow.webContents.getURL().includes(this.globals.THEIA_FRONTEND_HTML_PATH) || await this.checkSafeToStop(electronWindow, reason);
let currentUrl = electronWindow.webContents.getURL();
let frontendUri = this.globals.THEIA_FRONTEND_HTML_PATH;
// Since our resolved frontend HTML path might contain backward slashes on Windows, we normalize everything first.
if (isWindows) {
currentUrl = currentUrl.replace(/\\/g, '/');
frontendUri = frontendUri.replace(/\\/g, '/');
}
const safeToClose = !currentUrl.includes(frontendUri) || await this.checkSafeToStop(electronWindow, reason);
if (safeToClose) {
onSafeCallback();
}
Expand Down

0 comments on commit 52a6529

Please sign in to comment.