Skip to content

Commit 83b7ac3

Browse files
committed
Open external links in system browser
1 parent ae61c96 commit 83b7ac3

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/main/labview/labview.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import {
66
clipboard,
77
dialog,
88
Menu,
9-
MenuItemConstructorOptions
9+
MenuItemConstructorOptions,
10+
shell
1011
} from 'electron';
1112
import log from 'electron-log';
1213
import * as path from 'path';
@@ -63,6 +64,17 @@ export class LabView implements IDisposable {
6364
}
6465
});
6566

67+
// Open external links in system browser
68+
this._view.webContents.setWindowOpenHandler(({ url }) => {
69+
const jlab_host = `${sessionConfig.url.protocol}//${sessionConfig.url.host}`
70+
if (url.startsWith(jlab_host)) {
71+
return { action: 'allow'};
72+
} else {
73+
shell.openExternal(url);
74+
return { action: 'deny' };
75+
}
76+
});
77+
6678
this._view.setBackgroundColor(
6779
options.isDarkTheme ? DarkThemeBGColor : LightThemeBGColor
6880
);

0 commit comments

Comments
 (0)