mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-10 17:05:47 +00:00
Lint error fixed #126[WIP]
This commit is contained in:
@@ -68,13 +68,12 @@ function serverError(targetURL) {
|
|||||||
});
|
});
|
||||||
req.on('error', e => {
|
req.on('error', e => {
|
||||||
if (e.toString().indexOf('Error: self signed certificate') >= 0) {
|
if (e.toString().indexOf('Error: self signed certificate') >= 0) {
|
||||||
var url = targetURL.replace(/^https?:\/\//, '');
|
const url = targetURL.replace(/^https?:\/\//, '');
|
||||||
console.log('Server StatusCode:', 200);
|
console.log('Server StatusCode:', 200);
|
||||||
console.log('You are connected to:', url);
|
console.log('You are connected to:', url);
|
||||||
} else {
|
} else {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
req.end();
|
req.end();
|
||||||
} else if (data.domain) {
|
} else if (data.domain) {
|
||||||
@@ -256,27 +255,26 @@ function createMainWindow() {
|
|||||||
|
|
||||||
// For self-signed certificate
|
// For self-signed certificate
|
||||||
ipc.on('certificate-err', (e, domain) => {
|
ipc.on('certificate-err', (e, domain) => {
|
||||||
var detail = `URL: ${domain} \n Error: Self-Signed Certificate`;
|
const detail = `URL: ${domain} \n Error: Self-Signed Certificate`;
|
||||||
dialog.showMessageBox(mainWindow, {
|
dialog.showMessageBox(mainWindow, {
|
||||||
title: 'Certificate error',
|
title: 'Certificate error',
|
||||||
message: `Do you trust certificate from ${domain}?`,
|
message: `Do you trust certificate from ${domain}?`,
|
||||||
|
// eslint-disable-next-line object-shorthand
|
||||||
detail: detail,
|
detail: detail,
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
buttons: [
|
buttons: ['Yes', 'No'],
|
||||||
'Yes',
|
|
||||||
'No'
|
|
||||||
],
|
|
||||||
cancelId: 1
|
cancelId: 1
|
||||||
}, (response) => {
|
// eslint-disable-next-line object-shorthand
|
||||||
|
}, response => {
|
||||||
if (response === 0) {
|
if (response === 0) {
|
||||||
db.push("/certifiedURL", [{domain:domain}], false);
|
// eslint-disable-next-line object-shorthand
|
||||||
|
db.push('/certifiedURL', [{domain: domain}], false);
|
||||||
db.push('/domain', domain);
|
db.push('/domain', domain);
|
||||||
mainWindow.loadURL(domain);
|
mainWindow.loadURL(domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
// eslint-disable-next-line max-params
|
||||||
app.on('certificate-error', (event, webContents, url, error, certificate, callback) => {
|
app.on('certificate-error', (event, webContents, url, error, certificate, callback) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
callback(true);
|
callback(true);
|
||||||
|
|||||||
@@ -7,25 +7,21 @@ const db = new JsonDB(app.getPath('userData') + '/domain.json', true, true);
|
|||||||
const data = db.getData('/');
|
const data = db.getData('/');
|
||||||
|
|
||||||
if (!data.certifiedURL) {
|
if (!data.certifiedURL) {
|
||||||
db.push("/certifiedURL",[]);
|
db.push('/certifiedURL', []);
|
||||||
}
|
}
|
||||||
|
|
||||||
let URL_List = db.getData('/certifiedURL');
|
const UrlList = db.getData('/certifiedURL');
|
||||||
let URL_Length = URL_List.length;
|
const UrlLength = UrlList.length;
|
||||||
|
|
||||||
|
|
||||||
const checkURL = domain => {
|
const checkURL = domain => {
|
||||||
|
for (let i = 0; i < UrlLength; i++) {
|
||||||
for ( var i = 0; i < URL_Length; i++) {
|
if (UrlList[i].domain === domain) {
|
||||||
if (URL_List[i].domain === domain);
|
|
||||||
return true;
|
return true;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
window.addDomain = function () {
|
window.addDomain = function () {
|
||||||
const el = sel => {
|
const el = sel => {
|
||||||
return document.querySelector(sel);
|
return document.querySelector(sel);
|
||||||
|
|||||||
@@ -20,25 +20,21 @@ window.prefDomain = function () {
|
|||||||
const ipcRenderer = require('electron').ipcRenderer;
|
const ipcRenderer = require('electron').ipcRenderer;
|
||||||
const JsonDB = require('node-json-db');
|
const JsonDB = require('node-json-db');
|
||||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||||
const {
|
const {app} = require('electron').remote;
|
||||||
app
|
|
||||||
} = require('electron').remote;
|
|
||||||
|
|
||||||
const db = new JsonDB(app.getPath('userData') + '/domain.json', true, true);
|
const db = new JsonDB(app.getPath('userData') + '/domain.json', true, true);
|
||||||
|
|
||||||
let URL_List = db.getData('/certifiedURL');
|
const UrlList = db.getData('/certifiedURL');
|
||||||
|
|
||||||
let URL_Length = URL_List.length;
|
const UrlLength = UrlList.length;
|
||||||
|
|
||||||
const checkURL = domain => {
|
const checkURL = domain => {
|
||||||
|
for (let i = 0; i < UrlLength; i++) {
|
||||||
for ( var i = 0; i < URL_Length; i++) {
|
if (UrlList[i].domain === domain) {
|
||||||
if (URL_List[i].domain === domain);
|
|
||||||
return true;
|
return true;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let newDomain = document.getElementById('url').value;
|
let newDomain = document.getElementById('url').value;
|
||||||
@@ -82,9 +78,7 @@ window.prefDomain = function () {
|
|||||||
document.getElementById('main').innerHTML = 'Switch';
|
document.getElementById('main').innerHTML = 'Switch';
|
||||||
ipcRenderer.send('certificate-err', domain);
|
ipcRenderer.send('certificate-err', domain);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
document.getElementById('main').innerHTML = 'Switch';
|
document.getElementById('main').innerHTML = 'Switch';
|
||||||
document.getElementById('urladded').innerHTML = 'Not a valid Zulip Server.';
|
document.getElementById('urladded').innerHTML = 'Not a valid Zulip Server.';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user