Skip to content

Commit

Permalink
Fixed lint warnings: unicorn/prefer-string-slice
Browse files Browse the repository at this point in the history
Signed-off-by: Vitika9 <[email protected]>
  • Loading branch information
VitikaSoni committed Jan 30, 2023
1 parent f42d694 commit 099d933
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"prefer-destructuring": "error",
"unicorn/no-for-loop": "error",
"unicorn/prefer-includes": "error",
"unicorn/prefer-string-slice": "warn",
"unicorn/prefer-string-slice": "error",
"unicorn/filename-case": "warn",
"unicorn/prefer-query-selector": "error"
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/zapHomeFiles/hud/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ Vue.component('site-tree-node', {
if ((name.match(/\//g) || []).length > 2) {
// If there are more than 2 slashes just show last url element
// The first 2 slashes will be http(s)://...
name = name.substring(name.lastIndexOf('/') + 1);
name = name.slice(name.lastIndexOf('/') + 1);
}

if (isLeaf) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/zapHomeFiles/hud/target/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const injection = (function () {
const r = Math.floor(Math.random() * 1000);
const tabId = String(millis) + '-' + r;

return tabId.substring(6);
return tabId.slice(6);
}

/* TARGET INTERACTIONS */
Expand Down Expand Up @@ -623,8 +623,8 @@ const injection = (function () {
if (zapReplaceOffset > 0) {
// Hide the zapHudReplaceReq injected when resending a message in the browser
// But don't loose any fragment
const fragment = window.location.hash.substr(1);
let origUrl = window.location.href.substring(0, zapReplaceOffset - 1);
const fragment = window.location.hash.slice(1);
let origUrl = window.location.href.slice(0, zapReplaceOffset - 1);
if (fragment) {
origUrl += '#' + fragment;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/zapHomeFiles/hud/tools/commonAlerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const CommonAlerts = (function () {
if (zapReplaceOffset > 0) {
// Strip off the string used for resending in the browser
// Will be preceded by ? or &
origTarget = origTarget.substring(0, zapReplaceOffset - 1);
origTarget = origTarget.slice(0, zapReplaceOffset - 1);
}

let target = origTarget;
Expand Down
2 changes: 1 addition & 1 deletion src/main/zapHomeFiles/hud/tools/utils/alertUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const alertUtils = (function () {

if (target.indexOf('?') > 0) {
// Remove any url params
target = target.substring(0, target.indexOf('?'));
target = target.slice(0, target.indexOf('?'));
}

return apiCallWithResponse('alert', 'view', 'alertsByRisk', {url: target, recurse: 'false'});
Expand Down
48 changes: 24 additions & 24 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.substring(0, headerText.indexOf(' '));
headerText = headerText.substring(headerText.indexOf(' ') + 1);
header.method = headerText.slice(0, headerText.indexOf(' '));
headerText = headerText.slice(headerText.indexOf(' ') + 1);

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

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

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

if (!headerText.includes('\n')) {
value = headerText;
headerText = '';
} else {
value = headerText.substring(0, headerText.indexOf('\n'));
headerText = headerText.substring(headerText.indexOf('\n') + 1);
value = headerText.slice(0, headerText.indexOf('\n'));
headerText = headerText.slice(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.substring(0, headerText.indexOf(' '));
headerText = headerText.substring(headerText.indexOf(' ') + 1);
header.version = headerText.slice(0, headerText.indexOf(' '));
headerText = headerText.slice(headerText.indexOf(' ') + 1);

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

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

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

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

header.fields[field] = value;
}
Expand Down Expand Up @@ -136,7 +136,7 @@ const utils = (function () {
let end = url.indexOf('&', start);
end = end === -1 ? url.length : end;

return url.substring(start, end);
return url.slice(start, end);
}

/* STORAGE */
Expand Down Expand Up @@ -650,7 +650,7 @@ const utils = (function () {
scheme = 'http';
}

return scheme + '://' + domain + url.substring(url.indexOf(domain) + domain.length);
return scheme + '://' + domain + url.slice(url.indexOf(domain) + domain.length);
})
.catch(errorHandler);
}
Expand All @@ -665,8 +665,8 @@ const utils = (function () {
// Construct the stack trace
const lines = error.stack.split('\n').slice(0, -1);
lines.forEach(line => {
const functionName = line.substring(0, line.indexOf('/'));
const urlAndLineNo = line.substring(line.indexOf('http'), line.length - 1);
const functionName = line.slice(0, line.indexOf('/'));
const urlAndLineNo = line.slice(line.indexOf('http'), -1);
const parts = urlAndLineNo.split(':');
let url = parts[0] + ':' + parts[1];
let lineNo = parts[2] + ':' + parts[3];
Expand Down

0 comments on commit 099d933

Please sign in to comment.