Skip to content

Commit

Permalink
feat(app): disable external links from opening in ODD (#14472)
Browse files Browse the repository at this point in the history
closes RQA-2318
  • Loading branch information
shlokamin authored Feb 14, 2024
1 parent 14cfb6e commit fe3d91d
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions app-shell-odd/src/ui.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// sets up the main window ui
import { app, shell, BrowserWindow } from 'electron'
import { app, BrowserWindow } from 'electron'
import path from 'path'
import { sendReadyStatus } from '@opentrons/app/src/redux/shell'
import { getConfig } from './config'
Expand Down Expand Up @@ -58,14 +58,9 @@ export function createUi(dispatch: Dispatch): BrowserWindow {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
mainWindow.loadURL(url, { extraHeaders: 'pragma: no-cache\n' })

// open new windows (<a target="_blank" ...) in browser windows
mainWindow.webContents.setWindowOpenHandler(({ url, disposition }) => {
if (disposition === 'new-window' && url === 'about:blank') {
shell.openExternal(url)
return { action: 'deny' }
} else {
return { action: 'allow' }
}
// never allow external links to open
mainWindow.webContents.setWindowOpenHandler(() => {
return { action: 'deny' }
})

return mainWindow
Expand Down

0 comments on commit fe3d91d

Please sign in to comment.