From 57c363f956431de01e569a220b0d9374e04aef16 Mon Sep 17 00:00:00 2001 From: Vishwas Shashidhar Date: Mon, 1 Mar 2021 16:43:33 +0530 Subject: [PATCH] SDA-2977: UBS: Inconsistent 'Copy Email Address' output on MessageML (#1193) * fix: SDA-2948 (Redesign notification) (#1186) * fix: SDA-2948 - Redesign notification * fix: SDA-2948 - Fix background color * SDA-2977: add support for mailto links Co-authored-by: Kiran Niranjan --- src/app/child-window-handler.ts | 17 +++++------------ src/renderer/notification.ts | 24 ++++++++++++++++-------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/app/child-window-handler.ts b/src/app/child-window-handler.ts index 37282a4f..65a08682 100644 --- a/src/app/child-window-handler.ts +++ b/src/app/child-window-handler.ts @@ -36,25 +36,18 @@ const MIN_HEIGHT = 300; */ const verifyProtocolForNewUrl = (url: string): boolean => { const parsedUrl = parse(url); - if (!parsedUrl) { + if (!parsedUrl || !parsedUrl.protocol) { logger.info( `child-window-handler: The url ${url} doesn't have a protocol. Returning false for verification!`, ); return false; } + const allowedProtocols = ['http:', 'https:', 'mailto:']; // url parse returns protocol with : - if (parsedUrl.protocol === 'https:') { + if (allowedProtocols.includes(parsedUrl.protocol)) { logger.info( - `child-window-handler: The url ${url} is a https url! Returning true for verification!`, - ); - return true; - } - - // url parse returns protocol with : - if (parsedUrl.protocol === 'http:') { - logger.info( - `child-window-handler: The url ${url} is a http url! Returning true for verification!`, + `child-window-handler: Protocol of the url ${url} is whitelisted! Returning true for verification!`, ); return true; } @@ -303,7 +296,7 @@ export const handleChildWindow = (webContents: WebContents): void => { return; } logger.info(`child-window-handler: new window url is ${newWinUrl} which is not of the same host, - so opening it in the default browser!`); + so opening it in the default app!`); windowHandler.openUrlInDefaultBrowser(newWinUrl); } }; diff --git a/src/renderer/notification.ts b/src/renderer/notification.ts index 445d4b2e..2dc69138 100644 --- a/src/renderer/notification.ts +++ b/src/renderer/notification.ts @@ -434,16 +434,24 @@ class Notification extends NotificationHandler { ...this.activeNotifications, }; const inactiveNotificationWindows = { ...[], ...this.inactiveWindows }; - for (const activeWindow of activeNotificationWindows) { - if (activeWindow && windowExists(activeWindow)) { - await this.hideNotification( - (activeWindow as ICustomBrowserWindow).clientId, - ); + if (activeNotificationWindows && Array.isArray(activeNotificationWindows)) { + for (const activeWindow of activeNotificationWindows) { + if (activeWindow && windowExists(activeWindow)) { + await this.hideNotification( + (activeWindow as ICustomBrowserWindow).clientId, + ); + } } } - for (const inactiveWindow of inactiveNotificationWindows) { - if (inactiveWindow && windowExists(inactiveWindow)) { - inactiveWindow.close(); + + if ( + inactiveNotificationWindows && + Array.isArray(inactiveNotificationWindows) + ) { + for (const inactiveWindow of inactiveNotificationWindows) { + if (inactiveWindow && windowExists(inactiveWindow)) { + inactiveWindow.close(); + } } }