diff --git a/package-lock.json b/package-lock.json index 806ee327..3219b6fe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -40,7 +40,7 @@ "builder-util-runtime": "^9.0.3", "cross-env": "7.0.3", "del": "3.0.0", - "electron": "^27.2.0", + "electron": "^28.1.3", "electron-builder": "^24.2.1", "electron-icon-maker": "0.0.5", "electron-osx-sign": "^0.6.0", @@ -6633,9 +6633,9 @@ } }, "node_modules/electron": { - "version": "27.2.0", - "resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/electron/-/electron-27.2.0.tgz", - "integrity": "sha512-no/iMICVLI/5G0IqgKFbB89HDN88DWwKeRO+dPfJPkpJISdEX8Cx/sMEOFuuRa4VNInNe5CKCqRWExK5z3AdcQ==", + "version": "28.1.3", + "resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/electron/-/electron-28.1.3.tgz", + "integrity": "sha512-NSFyTo6SndTPXzU18XRePv4LnjmuM9rF5GMKta1/kPmi02ISoSRonnD7wUlWXD2x53XyJ6d/TbSVesMW6sXkEQ==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -22991,9 +22991,9 @@ } }, "electron": { - "version": "27.2.0", - "resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/electron/-/electron-27.2.0.tgz", - "integrity": "sha512-no/iMICVLI/5G0IqgKFbB89HDN88DWwKeRO+dPfJPkpJISdEX8Cx/sMEOFuuRa4VNInNe5CKCqRWExK5z3AdcQ==", + "version": "28.1.3", + "resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/electron/-/electron-28.1.3.tgz", + "integrity": "sha512-NSFyTo6SndTPXzU18XRePv4LnjmuM9rF5GMKta1/kPmi02ISoSRonnD7wUlWXD2x53XyJ6d/TbSVesMW6sXkEQ==", "dev": true, "requires": { "@electron/get": "^2.0.0", diff --git a/package.json b/package.json index a8b9c35a..a59b132b 100644 --- a/package.json +++ b/package.json @@ -177,7 +177,7 @@ "builder-util-runtime": "^9.0.3", "cross-env": "7.0.3", "del": "3.0.0", - "electron": "^27.2.0", + "electron": "^28.1.3", "electron-builder": "^24.2.1", "electron-icon-maker": "0.0.5", "electron-osx-sign": "^0.6.0", diff --git a/src/app/window-handler.ts b/src/app/window-handler.ts index 25bdc1eb..cf990636 100644 --- a/src/app/window-handler.ts +++ b/src/app/window-handler.ts @@ -77,6 +77,7 @@ import { initSysTray, injectStyles, isSymphonyReachable, + isValidUrl, loadBrowserViews, monitorNetworkInterception, preventWindowNavigation, @@ -130,8 +131,6 @@ export const IS_NODE_INTEGRATION_ENABLED: boolean = false; export const AUX_CLICK = 'Auxclick'; // Timeout on restarting SDA in case it's stuck const LISTEN_TIMEOUT: number = 25 * 1000; - -const HOSTNAME_REGEX = /^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; export class WindowHandler { /** * Verifies if the url is valid and @@ -2193,14 +2192,14 @@ export class WindowHandler { ); const userAgent = this.getUserAgent(this.mainWebContents); const urlFromConfig = config.getUserConfigFields(['url']); - const isValidUrl = - HOSTNAME_REGEX.test(urlFromConfig.url || '') || + const isPodUrlValid = + isValidUrl(urlFromConfig.url || '') || urlFromConfig.url.includes('https://local-dev.symphony.com'); await this.mainWebContents.loadURL( this.cmdUrl ? this.cmdUrl - : isValidUrl + : isPodUrlValid ? urlFromConfig.url : this.globalConfig.url, { @@ -2392,8 +2391,7 @@ export class WindowHandler { logger.info( `window-handler: Current main window url is ${webContentsUrl}.`, ); - const reloadUrl = - webContentsUrl || this.userConfig.url || this.globalConfig.url; + const reloadUrl = this.userConfig.url || this.globalConfig.url; logger.info(`window-handler: Trying to reload ${reloadUrl}.`); const userAgent = this.getUserAgent(this.mainWebContents); await this.mainWebContents.loadURL(reloadUrl, { userAgent }); diff --git a/src/app/window-utils.ts b/src/app/window-utils.ts index e7a26ff1..06b34579 100644 --- a/src/app/window-utils.ts +++ b/src/app/window-utils.ts @@ -1458,3 +1458,11 @@ export const hideFullscreenWindow = (window: BrowserWindow) => { }); window.setFullScreen(false); }; + +export const isValidUrl = (text: string): false | URL => { + try { + return new URL(text); + } catch (err) { + return false; + } +};