Skip to content

Commit b695eea

Browse files
committed
Revert "fix lint errors"
This reverts commit 422853d. Signed-off-by: Najam Ul Saqib <najamulsaqib@tutamail.com>
1 parent 0da80f6 commit b695eea

File tree

1 file changed

+41
-37
lines changed

1 file changed

+41
-37
lines changed

src/main/zapHomeFiles/hud/utils.js

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,27 @@ const utils = (function () {
4343
function parseRequestHeader(headerText) {
4444
const header = {};
4545

46-
header.method = headerText.slice(0, Math.max(0, headerText.indexOf(' ')));
47-
headerText = headerText.slice(Math.max(0, headerText.indexOf(' ') + 1));
46+
header.method = headerText.substring(0, headerText.indexOf(' '));
47+
headerText = headerText.substring(headerText.indexOf(' ') + 1);
4848

49-
header.uri = headerText.slice(0, Math.max(0, headerText.indexOf(' ')));
50-
headerText = headerText.slice(Math.max(0, headerText.indexOf(' ') + 1));
49+
header.uri = headerText.substring(0, headerText.indexOf(' '));
50+
headerText = headerText.substring(headerText.indexOf(' ') + 1);
5151

52-
header.version = headerText.slice(0, Math.max(0, headerText.indexOf('\r')));
53-
headerText = headerText.slice(Math.max(0, headerText.indexOf('\n') + 1));
52+
header.version = headerText.substring(0, headerText.indexOf('\r'));
53+
headerText = headerText.substring(headerText.indexOf('\n') + 1);
5454

5555
header.fields = {};
5656
while (headerText !== '') {
57-
const field = headerText.slice(0, Math.max(0, headerText.indexOf(':')));
58-
headerText = headerText.slice(Math.max(0, headerText.indexOf(':') + 2));
57+
const field = headerText.substring(0, headerText.indexOf(':'));
58+
headerText = headerText.substring(headerText.indexOf(':') + 2);
5959
let value;
6060

61-
if (!headerText.includes('\n')) {
61+
if (headerText.indexOf('\n') < 0) {
6262
value = headerText;
6363
headerText = '';
6464
} else {
65-
value = headerText.slice(0, Math.max(0, headerText.indexOf('\n')));
66-
headerText = headerText.slice(Math.max(0, headerText.indexOf('\n') + 1));
65+
value = headerText.substring(0, headerText.indexOf('\n'));
66+
headerText = headerText.substring(headerText.indexOf('\n') + 1);
6767
}
6868

6969
header.fields[field] = value;
@@ -78,22 +78,22 @@ const utils = (function () {
7878
function parseResponseHeader(headerText) {
7979
const header = {};
8080

81-
header.version = headerText.slice(0, Math.max(0, headerText.indexOf(' ')));
82-
headerText = headerText.slice(Math.max(0, headerText.indexOf(' ') + 1));
81+
header.version = headerText.substring(0, headerText.indexOf(' '));
82+
headerText = headerText.substring(headerText.indexOf(' ') + 1);
8383

84-
header.status = headerText.slice(0, Math.max(0, headerText.indexOf(' ')));
85-
headerText = headerText.slice(Math.max(0, headerText.indexOf(' ') + 1));
84+
header.status = headerText.substring(0, headerText.indexOf(' '));
85+
headerText = headerText.substring(headerText.indexOf(' ') + 1);
8686

87-
header.reason = headerText.slice(0, Math.max(0, headerText.indexOf(' ')));
88-
headerText = headerText.slice(Math.max(0, headerText.indexOf(' ') + 1));
87+
header.reason = headerText.substring(0, headerText.indexOf(' '));
88+
headerText = headerText.substring(headerText.indexOf(' ') + 1);
8989

9090
header.fields = {};
9191
while (headerText !== '') {
92-
const field = headerText.slice(0, Math.max(0, headerText.indexOf(':')));
93-
headerText = headerText.slice(Math.max(0, headerText.indexOf(':') + 2));
92+
const field = headerText.substring(0, headerText.indexOf(':'));
93+
headerText = headerText.substring(headerText.indexOf(':') + 2);
9494

95-
const value = headerText.slice(0, Math.max(0, headerText.indexOf('\n')));
96-
headerText = headerText.slice(Math.max(0, headerText.indexOf('\n') + 1));
95+
const value = headerText.substring(0, headerText.indexOf('\n'));
96+
headerText = headerText.substring(headerText.indexOf('\n') + 1);
9797

9898
header.fields[field] = value;
9999
}
@@ -121,11 +121,11 @@ const utils = (function () {
121121
hostname = hostname.split('?')[0];
122122
hostname = hostname.split('#')[0];
123123

124-
// Remove port if present
125-
hostname = hostname.split(':')[0];
124+
// Remove port if present
125+
hostname = hostname.split(':')[0];
126126

127127
// Split the hostname into parts
128-
const parts = hostname.split('.');
128+
const parts = hostname.split('.');
129129

130130
// If the hostname has more than two parts, return the last two parts as the domain
131131
if (parts.length > 2) {
@@ -136,7 +136,7 @@ const utils = (function () {
136136
}
137137

138138
function hasScheme(url) {
139-
return url.includes('://');
139+
return url.indexOf('://') > -1;
140140
}
141141

142142
/*
@@ -163,7 +163,7 @@ const utils = (function () {
163163
* Initialize all of the info that will be stored in indexeddb.
164164
*/
165165
function initializeHUD(leftTools, rightTools, drawer) {
166-
if (IS_DEV_MODE && !leftTools.includes('hudErrors')) {
166+
if (IS_DEV_MODE && leftTools.indexOf('hudErrors') < 0) {
167167
// Always add the error tool in dev mode
168168
leftTools.push('hudErrors');
169169
}
@@ -206,8 +206,8 @@ const utils = (function () {
206206
function setDefaultTools(leftTools, rightTools) {
207207
const promises = [];
208208

209-
for (const [i, leftTool] of leftTools.entries()) {
210-
loadTool(leftTool)
209+
for (let i = 0; i < leftTools.length; i++) {
210+
loadTool(leftTools[i])
211211
.then(tool => {
212212
if (!tool) {
213213
log(LOG_ERROR, 'utils.setDefaultTools', 'Failed to load tool.', tool.name);
@@ -223,8 +223,8 @@ const utils = (function () {
223223
.catch(errorHandler);
224224
}
225225

226-
for (const [i, rightTool] of rightTools.entries()) {
227-
loadTool(rightTool)
226+
for (let i = 0; i < rightTools.length; i++) {
227+
loadTool(rightTools[i])
228228
.then(tool => {
229229
if (!tool) {
230230
log(LOG_ERROR, 'utils.setDefaultTools', 'Failed to load tool.', tool.name);
@@ -441,7 +441,8 @@ const utils = (function () {
441441
function messageFrame(tabId, frameId, message) {
442442
return clients.matchAll({includeUncontrolled: true})
443443
.then(clients => {
444-
for (const client of clients) {
444+
for (let i = 0; i < clients.length; i++) {
445+
const client = clients[i];
445446
const parameters = new URL(client.url).searchParams;
446447

447448
const tid = parameters.get('tabId');
@@ -479,7 +480,8 @@ const utils = (function () {
479480
.then(clients => {
480481
const frameClients = [];
481482

482-
for (const client of clients) {
483+
for (let i = 0; i < clients.length; i++) {
484+
const client = clients[i];
483485
const parameters = new URL(client.url).searchParams;
484486

485487
const fid = parameters.get('frameId');
@@ -498,7 +500,9 @@ const utils = (function () {
498500
})
499501
.then(clients => {
500502
return new Promise(((resolve, reject) => {
501-
for (const client of clients) {
503+
for (let i = 0; i < clients.length; i++) {
504+
const client = clients[i];
505+
502506
const channel = new MessageChannel();
503507
channel.port1.start();
504508
channel.port2.start();
@@ -531,7 +535,8 @@ const utils = (function () {
531535
.then(clients => {
532536
const frameClients = [];
533537

534-
for (const client of clients) {
538+
for (let i = 0; i < clients.length; i++) {
539+
const client = clients[i];
535540
const parameters = new URL(client.url).searchParams;
536541

537542
const fid = parameters.get('frameId');
@@ -661,7 +666,7 @@ const utils = (function () {
661666
scheme = 'http';
662667
}
663668

664-
return scheme + '://' + domain + url.slice(Math.max(0, url.indexOf(domain) + domain.length));
669+
return scheme + '://' + domain + url.substring(url.indexOf(domain) + domain.length);
665670
})
666671
.catch(errorHandler);
667672
}
@@ -676,7 +681,7 @@ const utils = (function () {
676681
// Construct the stack trace
677682
const lines = error.stack.split('\n').slice(0, -1);
678683
lines.forEach(line => {
679-
const functionName = line.slice(0, Math.max(0, line.indexOf('/')));
684+
const functionName = line.substring(0, line.indexOf('/'));
680685
const urlAndLineNo = line.substring(line.indexOf('http'), line.length - 1);
681686
const parts = urlAndLineNo.split(':');
682687
let url = parts[0] + ':' + parts[1];
@@ -777,7 +782,6 @@ const utils = (function () {
777782
timestampToTimeString
778783
};
779784
}
780-
781785
return {
782786
parseRequestHeader,
783787
parseResponseHeader,

0 commit comments

Comments
 (0)