Allow popups to be opened when their url starts with the referrer url

This commit is contained in:
Alice Gaudon 2022-03-17 12:56:40 +01:00
parent ab38ff51dc
commit 18c3219e9b

View File

@ -76,6 +76,8 @@ export default class Application {
if (contents.getType() === 'webview') { if (contents.getType() === 'webview') {
console.log('Setting external links to open in default OS browser'); console.log('Setting external links to open in default OS browser');
contents.setWindowOpenHandler(details => { contents.setWindowOpenHandler(details => {
if (details.url.startsWith(details.referrer.url)) return {action: 'allow'};
const url = details.url; const url = details.url;
this.openExternalLink(url) this.openExternalLink(url)
.catch(console.error); .catch(console.error);