File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -293,11 +293,19 @@ async function createWindow(): Promise<void> {
293
293
}
294
294
state . mainWindow . webContents . setWindowOpenHandler ( ( { url } ) => {
295
295
console . log ( "Attempting to open URL:" , url )
296
- if ( url . includes ( "google.com" ) || url . includes ( "supabase.co" ) ) {
297
- shell . openExternal ( url )
298
- return { action : "deny" }
296
+ try {
297
+ const parsedURL = new URL ( url ) ;
298
+ const hostname = parsedURL . hostname ;
299
+ const allowedHosts = [ "google.com" , "supabase.co" ] ;
300
+ if ( allowedHosts . includes ( hostname ) || hostname . endsWith ( ".google.com" ) || hostname . endsWith ( ".supabase.co" ) ) {
301
+ shell . openExternal ( url ) ;
302
+ return { action : "deny" } ; // Do not open this URL in a new Electron window
303
+ }
304
+ } catch ( error ) {
305
+ console . error ( "Invalid URL %d in setWindowOpenHandler: %d" , url , error ) ;
306
+ return { action : "deny" } ; // Deny access as URL string is malformed or invalid
299
307
}
300
- return { action : "allow" }
308
+ return { action : "allow" } ;
301
309
} )
302
310
303
311
// Enhanced screen capture resistance
You can’t perform that action at this time.
0 commit comments