mirror of
https://github.com/OutlineFoundation/outline-server.git
synced 2026-10-24 21:41:16 +00:00
Filter URL type before calling openExternal
This commit is contained in:
parent
23e35e1942
commit
e8bf9cacae
1 changed files with 10 additions and 1 deletions
|
|
@ -88,7 +88,16 @@ function createMainWindow() {
|
|||
const LOADING_WINDOW_DELAY_MS = 3000;
|
||||
|
||||
const handleNavigation = (event: Event, url: string) => {
|
||||
shell.openExternal(url);
|
||||
try {
|
||||
const parsed: URL = new URL(url);
|
||||
if (parsed.protocol === 'http:' || parsed.protocol === 'https:') {
|
||||
shell.openExternal(url);
|
||||
} else {
|
||||
console.warn(`Refusing to open URL with protocol "${parsed.protocol}"`);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('Could not parse URL: ' + url);
|
||||
}
|
||||
event.preventDefault();
|
||||
};
|
||||
win.webContents.on('will-navigate', (event: Event, url: string) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue