SDA-4450 pod load failure should retry loading pod URL from config (#2069)

* SDA-4450 pod load failure should retry loading pod URL from config

* Upgrade electron@28.1.3

* SDA-4450 Fix wrong regex on pod url check
This commit is contained in:
Salah Benmoussati 2024-01-15 15:49:58 +01:00 committed by GitHub
parent b862bd5561
commit bafe62616d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 15 deletions

14
package-lock.json generated
View File

@ -40,7 +40,7 @@
"builder-util-runtime": "^9.0.3", "builder-util-runtime": "^9.0.3",
"cross-env": "7.0.3", "cross-env": "7.0.3",
"del": "3.0.0", "del": "3.0.0",
"electron": "^27.2.0", "electron": "^28.1.3",
"electron-builder": "^24.2.1", "electron-builder": "^24.2.1",
"electron-icon-maker": "0.0.5", "electron-icon-maker": "0.0.5",
"electron-osx-sign": "^0.6.0", "electron-osx-sign": "^0.6.0",
@ -6633,9 +6633,9 @@
} }
}, },
"node_modules/electron": { "node_modules/electron": {
"version": "27.2.0", "version": "28.1.3",
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/electron/-/electron-27.2.0.tgz", "resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/electron/-/electron-28.1.3.tgz",
"integrity": "sha512-no/iMICVLI/5G0IqgKFbB89HDN88DWwKeRO+dPfJPkpJISdEX8Cx/sMEOFuuRa4VNInNe5CKCqRWExK5z3AdcQ==", "integrity": "sha512-NSFyTo6SndTPXzU18XRePv4LnjmuM9rF5GMKta1/kPmi02ISoSRonnD7wUlWXD2x53XyJ6d/TbSVesMW6sXkEQ==",
"dev": true, "dev": true,
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
@ -22991,9 +22991,9 @@
} }
}, },
"electron": { "electron": {
"version": "27.2.0", "version": "28.1.3",
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/electron/-/electron-27.2.0.tgz", "resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/electron/-/electron-28.1.3.tgz",
"integrity": "sha512-no/iMICVLI/5G0IqgKFbB89HDN88DWwKeRO+dPfJPkpJISdEX8Cx/sMEOFuuRa4VNInNe5CKCqRWExK5z3AdcQ==", "integrity": "sha512-NSFyTo6SndTPXzU18XRePv4LnjmuM9rF5GMKta1/kPmi02ISoSRonnD7wUlWXD2x53XyJ6d/TbSVesMW6sXkEQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"@electron/get": "^2.0.0", "@electron/get": "^2.0.0",

View File

@ -177,7 +177,7 @@
"builder-util-runtime": "^9.0.3", "builder-util-runtime": "^9.0.3",
"cross-env": "7.0.3", "cross-env": "7.0.3",
"del": "3.0.0", "del": "3.0.0",
"electron": "^27.2.0", "electron": "^28.1.3",
"electron-builder": "^24.2.1", "electron-builder": "^24.2.1",
"electron-icon-maker": "0.0.5", "electron-icon-maker": "0.0.5",
"electron-osx-sign": "^0.6.0", "electron-osx-sign": "^0.6.0",

View File

@ -77,6 +77,7 @@ import {
initSysTray, initSysTray,
injectStyles, injectStyles,
isSymphonyReachable, isSymphonyReachable,
isValidUrl,
loadBrowserViews, loadBrowserViews,
monitorNetworkInterception, monitorNetworkInterception,
preventWindowNavigation, preventWindowNavigation,
@ -130,8 +131,6 @@ export const IS_NODE_INTEGRATION_ENABLED: boolean = false;
export const AUX_CLICK = 'Auxclick'; export const AUX_CLICK = 'Auxclick';
// Timeout on restarting SDA in case it's stuck // Timeout on restarting SDA in case it's stuck
const LISTEN_TIMEOUT: number = 25 * 1000; const LISTEN_TIMEOUT: number = 25 * 1000;
const HOSTNAME_REGEX = /^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
export class WindowHandler { export class WindowHandler {
/** /**
* Verifies if the url is valid and * Verifies if the url is valid and
@ -2193,14 +2192,14 @@ export class WindowHandler {
); );
const userAgent = this.getUserAgent(this.mainWebContents); const userAgent = this.getUserAgent(this.mainWebContents);
const urlFromConfig = config.getUserConfigFields(['url']); const urlFromConfig = config.getUserConfigFields(['url']);
const isValidUrl = const isPodUrlValid =
HOSTNAME_REGEX.test(urlFromConfig.url || '') || isValidUrl(urlFromConfig.url || '') ||
urlFromConfig.url.includes('https://local-dev.symphony.com'); urlFromConfig.url.includes('https://local-dev.symphony.com');
await this.mainWebContents.loadURL( await this.mainWebContents.loadURL(
this.cmdUrl this.cmdUrl
? this.cmdUrl ? this.cmdUrl
: isValidUrl : isPodUrlValid
? urlFromConfig.url ? urlFromConfig.url
: this.globalConfig.url, : this.globalConfig.url,
{ {
@ -2392,8 +2391,7 @@ export class WindowHandler {
logger.info( logger.info(
`window-handler: Current main window url is ${webContentsUrl}.`, `window-handler: Current main window url is ${webContentsUrl}.`,
); );
const reloadUrl = const reloadUrl = this.userConfig.url || this.globalConfig.url;
webContentsUrl || this.userConfig.url || this.globalConfig.url;
logger.info(`window-handler: Trying to reload ${reloadUrl}.`); logger.info(`window-handler: Trying to reload ${reloadUrl}.`);
const userAgent = this.getUserAgent(this.mainWebContents); const userAgent = this.getUserAgent(this.mainWebContents);
await this.mainWebContents.loadURL(reloadUrl, { userAgent }); await this.mainWebContents.loadURL(reloadUrl, { userAgent });

View File

@ -1458,3 +1458,11 @@ export const hideFullscreenWindow = (window: BrowserWindow) => {
}); });
window.setFullScreen(false); window.setFullScreen(false);
}; };
export const isValidUrl = (text: string): false | URL => {
try {
return new URL(text);
} catch (err) {
return false;
}
};