Skip to content

Commit ea6e8b7

Browse files
committed
prevent navigation to external links
1 parent 559bd72 commit ea6e8b7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,10 @@ app.on('ready', () => {
190190
});
191191

192192
app.on("web-contents-created", (_event: any, webContents: WebContents) => {
193-
// Prevent navigation to local links
193+
// Prevent navigation to local links on the same page and external links
194194
webContents.on('will-navigate', (event: Event, navigationUrl) => {
195195
const jlabBaseUrl = `http://localhost:${appConfig.jlabPort}/`;
196-
if (navigationUrl.startsWith(jlabBaseUrl) && navigationUrl.indexOf('#') !== -1) {
196+
if (!(navigationUrl.startsWith(jlabBaseUrl) && navigationUrl.indexOf('#') === -1)) {
197197
console.warn(`Navigation is not allowed; attempted navigation to: ${navigationUrl}`);
198198
event.preventDefault();
199199
}

0 commit comments

Comments
 (0)