diff --git a/README.md b/README.md index 31d4325..c383ec7 100644 --- a/README.md +++ b/README.md @@ -72,10 +72,11 @@ For other distributions please follow your specific steps. ```json { - "urlMainWindow": "https://customurl.example/", - "urlsInternal": ["customurl.example"], - "urlsExternal": ["externalurls.example"], - "showWindowFrame": true + "urlMainWindow":"https://customurl.example/", + "deeplinkUrls":["customurl.example"], + "outlookUrls":["outlookurls.example"], + "externalUrls": ["externalurls.example"], + "showWindowFrame":true } ``` @@ -88,11 +89,12 @@ Outlook.com account: ```json { "urlMainWindow": "https://outlook.live.com/mail", - "urlsInternal": ["outlook.com", "live.com"], - "urlsExternal": ["outlook.com", "live.com"] + "deeplinkUrls": ["outlook.com", "live.com"], + "outlookUrls": ["outlook.com", "live.com"] } ``` + ### Architecture components The main software architecture components and their versions are this: diff --git a/src/controller/mail-window-controller.js b/src/controller/mail-window-controller.js index 67f9360..7375cf2 100644 --- a/src/controller/mail-window-controller.js +++ b/src/controller/mail-window-controller.js @@ -11,8 +11,10 @@ const settings = require("electron-settings"); const getClientFile = require("./client-injector"); const path = require("path"); + let outlookUrl; let deeplinkUrls; +let externalUrls; let outlookUrls; let showWindowFrame; let $this; @@ -47,10 +49,14 @@ class MailWindowController { "outlook.office365.com", "outlook.office.com", ]; + externalUrls = settings.getSync('externalUrls') || [ + 'outlook.office.com/mail/safelink.html' + ] console.log("Loaded settings", { outlookUrl: outlookUrl, deeplinkUrls: deeplinkUrls, outlookUrls: outlookUrls, + externalUrls: externalUrls, }); } init() { @@ -195,20 +201,27 @@ class MailWindowController { openInBrowser(e, url, frameName, disposition, options) { console.log("Open in browser: " + url); //frameName,disposition,options) - if (new RegExp(deeplinkUrls.join("|")).test(url)) { - // Default action - if the user wants to open mail in a new window - let them. - //e.preventDefault() - console.log("Is deeplink"); - options.webPreferences.affinity = "main-window"; - } else if (new RegExp(outlookUrls.join("|")).test(url)) { - // Open calendar, contacts and tasks in the same window - e.preventDefault(); - this.loadURL(url); - } else { - // Send everything else to the browser - e.preventDefault(); - shell.openExternal(url); + + if (!new RegExp(externalUrls.join("|")).test(url)) { + if (new RegExp(deeplinkUrls.join("|")).test(url)) { + // Default action - if the user wants to open mail in a new window - let them. + //e.preventDefault() + console.log("Is deeplink, open in main window"); + options.webPreferences.affinity = "main-window"; + return; + } + if (new RegExp(outlookUrls.join("|")).test(url)) { + // Open calendar, contacts and tasks in the same window + console.log("Is outlook URL, open in application"); + e.preventDefault(); + this.loadURL(url); + return; + } } + // Send everything else to the browser + console.log("Is external URL, open in browser"); + e.preventDefault(); + shell.openExternal(url); } show() { @@ -253,7 +266,6 @@ class MailWindowController { ); } //console.log(params) - for (const flag in params.editFlags) { let actionLabel = flag.substring(3); //remove "can" if (flag == "canSelectAll") {