Skip to content

Commit ee372c1

Browse files
trop[bot]miniak
andauthored
fix: isTrustedSender() in test-app (electron#24230)
Co-authored-by: Milan Burda <milan.burda@gmail.com>
1 parent 53bdc4a commit ee372c1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

default_app/default_app.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { app, dialog, BrowserWindow, shell, ipcMain } from 'electron';
22
import * as path from 'path';
3+
import * as url from 'url';
34

45
let mainWindow: BrowserWindow | null = null;
56

@@ -29,12 +30,11 @@ function isTrustedSender (webContents: Electron.WebContents) {
2930
return false;
3031
}
3132

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

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

0 commit comments

Comments
 (0)