Skip to content

Commit

Permalink
fix: isTrustedSender() in test-app (#24232)
Browse files Browse the repository at this point in the history
Co-authored-by: Milan Burda <[email protected]>
  • Loading branch information
trop[bot] and miniak authored Jun 22, 2020
1 parent d321e29 commit 3704dc9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions default_app/default_app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { app, dialog, BrowserWindow, shell, ipcMain } from 'electron';
import * as path from 'path';
import * as url from 'url';

let mainWindow: BrowserWindow | null = null;

Expand Down Expand Up @@ -29,12 +30,11 @@ function isTrustedSender (webContents: Electron.WebContents) {
return false;
}

const parsedUrl = new URL(webContents.getURL());
const urlPath = process.platform === 'win32'
// Strip the prefixed "/" that occurs on windows
? path.resolve(parsedUrl.pathname.substr(1))
: parsedUrl.pathname;
return parsedUrl.protocol === 'file:' && urlPath === indexPath;
try {
return url.fileURLToPath(webContents.getURL()) === indexPath;
} catch {
return false;
}
}

ipcMain.handle('bootstrap', (event) => {
Expand Down

0 comments on commit 3704dc9

Please sign in to comment.