Merge pull request #147 from ente-io/open-external-link-in-browser

open non desktop specific URLs in external browser
This commit is contained in:
Abhinav Kumar 2023-02-10 21:31:04 +05:30 committed by GitHub
commit fe65252a5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View file

@ -14,6 +14,7 @@ import {
handleDockIconHideOnAutoLaunch,
handleUpdates,
logSystemInfo,
handleExternalLinks,
} from './utils/main';
import { initSentry } from './services/sentry';
import { setupLogging } from './utils/logging';
@ -79,6 +80,7 @@ if (!gotTheLock) {
setupIpcComs(tray, mainWindow, watcher);
handleUpdates(mainWindow);
handleDownloads(mainWindow);
handleExternalLinks(mainWindow);
addAllowOriginHeader(mainWindow);
});

View file

@ -104,3 +104,14 @@ export function logSystemInfo() {
const osRelease = os.release();
ElectronLog.info({ osName, osRelease, systemVersion });
}
export function handleExternalLinks(mainWindow: BrowserWindow) {
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
if (!url.startsWith(PROD_HOST_URL)) {
require('electron').shell.openExternal(url);
return { action: 'deny' };
} else {
return { action: 'allow' };
}
});
}