Electron 385: add support for custom tlds (#347)

- add logic setting ntlm on default session
- add logic to include custom tlds
- fix failing tests
This commit is contained in:
Vishwas Shashidhar 2018-04-30 17:32:10 +05:30 committed by GitHub
parent ab978399ff
commit 9a11bf90e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 3 deletions

View File

@ -5,6 +5,7 @@
"alwaysOnTop" : false,
"bringToFront": false,
"whitelistUrl": "*",
"customTlds": [],
"isCustomTitleBar": true,
"memoryRefresh": true,
"notificationSettings": {

View File

@ -3,6 +3,23 @@
const { getGlobalConfigField } = require('./../config.js');
const parseDomain = require('parse-domain');
const isEqual = require('lodash.isequal');
const log = require('../log.js');
const logLevels = require('../enums/logLevels.js');
let customTlds = [];
getGlobalConfigField('customTlds')
.then((domains) => {
if (domains && Array.isArray(domains) && domains.length > 0) {
log.send(logLevels.INFO, `setting custom tlds that are -> ${domains}`);
customTlds = domains;
}
})
.catch((err) => {
log.send(logLevels.INFO, `error setting custom tlds -> ${err}`);
});
/**
* Loops through the list of whitelist urls
@ -35,7 +52,7 @@ function isWhitelisted(url) {
*/
function checkWhitelist(url, whitelist) {
let whitelistArray = whitelist.split(',');
const parsedUrl = parseDomain(url);
const parsedUrl = parseDomain(url, {customTlds});
if (!parsedUrl) {
return false;

View File

@ -3,6 +3,7 @@
const fs = require('fs');
const electron = require('electron');
const app = electron.app;
const electronSession = electron.session;
const globalShortcut = electron.globalShortcut;
const BrowserWindow = electron.BrowserWindow;
const path = require('path');
@ -19,7 +20,7 @@ const logLevels = require('./enums/logLevels.js');
const notify = require('./notify/electron-notify.js');
const eventEmitter = require('./eventEmitter');
const throttle = require('./utils/throttle.js');
const { getConfigField, updateConfigField, getGlobalConfigField } = require('./config.js');
const { getConfigField, updateConfigField, getGlobalConfigField, readConfigFileSync } = require('./config.js');
const { isMac, isNodeEnv, isWindows10, isWindowsOS } = require('./utils/misc');
const { deleteIndexFolder } = require('./search/search.js');
const { isWhitelisted } = require('./utils/whitelistHandler');
@ -120,7 +121,20 @@ function doCreateMainWindow(initialUrl, initialBounds, isCustomTitleBar) {
const isCustomTitleBarEnabled = typeof isCustomTitleBar === 'boolean' && isCustomTitleBar && isWindows10();
log.send(logLevels.INFO, 'creating main window url: ' + url);
let config = readConfigFileSync();
if (config && config !== null && config.customFlags) {
log.send(logLevels.INFO, 'Chrome flags config found!');
if (config.customFlags.authServerWhitelist && config.customFlags.authServerWhitelist !== "") {
log.send(logLevels.INFO, 'setting ntlm domains');
electronSession.defaultSession.allowNTLMCredentialsForDomains(config.customFlags.authServerWhitelist);
}
}
let newWinOpts = {
title: 'Symphony',
show: true,