Skip to content

Commit

Permalink
Revert "fix lint errors"
Browse files Browse the repository at this point in the history
This reverts commit 422853d.
  • Loading branch information
njmulsqb committed Jan 2, 2025
1 parent d872df2 commit 64c1da2
Showing 1 changed file with 41 additions and 37 deletions.
78 changes: 41 additions & 37 deletions src/main/zapHomeFiles/hud/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,27 @@ const utils = (function () {
function parseRequestHeader(headerText) {
const header = {};

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

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

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

header.fields = {};
while (headerText !== '') {
const field = headerText.slice(0, Math.max(0, headerText.indexOf(':')));
headerText = headerText.slice(Math.max(0, headerText.indexOf(':') + 2));
const field = headerText.substring(0, headerText.indexOf(':'));
headerText = headerText.substring(headerText.indexOf(':') + 2);
let value;

if (!headerText.includes('\n')) {
if (headerText.indexOf('\n') < 0) {
value = headerText;
headerText = '';
} else {
value = headerText.slice(0, Math.max(0, headerText.indexOf('\n')));
headerText = headerText.slice(Math.max(0, headerText.indexOf('\n') + 1));
value = headerText.substring(0, headerText.indexOf('\n'));
headerText = headerText.substring(headerText.indexOf('\n') + 1);
}

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

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

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

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

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

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

header.fields[field] = value;
}
Expand Down Expand Up @@ -121,11 +121,11 @@ const utils = (function () {
hostname = hostname.split('?')[0];
hostname = hostname.split('#')[0];

// Remove port if present
hostname = hostname.split(':')[0];
// Remove port if present
hostname = hostname.split(':')[0];

// Split the hostname into parts
const parts = hostname.split('.');
const parts = hostname.split('.');

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

function hasScheme(url) {
return url.includes('://');
return url.indexOf('://') > -1;
}

/*
Expand All @@ -163,7 +163,7 @@ const utils = (function () {
* Initialize all of the info that will be stored in indexeddb.
*/
function initializeHUD(leftTools, rightTools, drawer) {
if (IS_DEV_MODE && !leftTools.includes('hudErrors')) {
if (IS_DEV_MODE && leftTools.indexOf('hudErrors') < 0) {
// Always add the error tool in dev mode
leftTools.push('hudErrors');
}
Expand Down Expand Up @@ -206,8 +206,8 @@ const utils = (function () {
function setDefaultTools(leftTools, rightTools) {
const promises = [];

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

for (const [i, rightTool] of rightTools.entries()) {
loadTool(rightTool)
for (let i = 0; i < rightTools.length; i++) {
loadTool(rightTools[i])
.then(tool => {
if (!tool) {
log(LOG_ERROR, 'utils.setDefaultTools', 'Failed to load tool.', tool.name);
Expand Down Expand Up @@ -441,7 +441,8 @@ const utils = (function () {
function messageFrame(tabId, frameId, message) {
return clients.matchAll({includeUncontrolled: true})
.then(clients => {
for (const client of clients) {
for (let i = 0; i < clients.length; i++) {
const client = clients[i];
const parameters = new URL(client.url).searchParams;

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

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

const fid = parameters.get('frameId');
Expand All @@ -498,7 +500,9 @@ const utils = (function () {
})
.then(clients => {
return new Promise(((resolve, reject) => {
for (const client of clients) {
for (let i = 0; i < clients.length; i++) {
const client = clients[i];

const channel = new MessageChannel();
channel.port1.start();
channel.port2.start();
Expand Down Expand Up @@ -531,7 +535,8 @@ const utils = (function () {
.then(clients => {
const frameClients = [];

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

const fid = parameters.get('frameId');
Expand Down Expand Up @@ -661,7 +666,7 @@ const utils = (function () {
scheme = 'http';
}

return scheme + '://' + domain + url.slice(Math.max(0, url.indexOf(domain) + domain.length));
return scheme + '://' + domain + url.substring(url.indexOf(domain) + domain.length);
})
.catch(errorHandler);
}
Expand All @@ -676,7 +681,7 @@ const utils = (function () {
// Construct the stack trace
const lines = error.stack.split('\n').slice(0, -1);
lines.forEach(line => {
const functionName = line.slice(0, Math.max(0, line.indexOf('/')));
const functionName = line.substring(0, line.indexOf('/'));
const urlAndLineNo = line.substring(line.indexOf('http'), line.length - 1);
const parts = urlAndLineNo.split(':');
let url = parts[0] + ':' + parts[1];
Expand Down Expand Up @@ -777,7 +782,6 @@ const utils = (function () {
timestampToTimeString
};
}

return {
parseRequestHeader,
parseResponseHeader,
Expand Down

0 comments on commit 64c1da2

Please sign in to comment.