Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(app): disable external links from opening in ODD #14472

Merged
merged 2 commits into from
Feb 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
// 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' }

Check warning on line 63 in app-shell-odd/src/ui.ts

View check run for this annotation

Codecov / codecov/patch

app-shell-odd/src/ui.ts#L62-L63

Added lines #L62 - L63 were not covered by tests
})

return mainWindow
Expand Down
Loading