Skip to content

Commit 76c7889

Browse files
committed
Fixed lint warnings: unicorn/prefer-string-slice
Signed-off-by: Vitika9 <[email protected]>
1 parent f42d694 commit 76c7889

File tree

6 files changed

+31
-31
lines changed

6 files changed

+31
-31
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
"prefer-destructuring": "error",
8181
"unicorn/no-for-loop": "error",
8282
"unicorn/prefer-includes": "error",
83-
"unicorn/prefer-string-slice": "warn",
83+
"unicorn/prefer-string-slice": "error",
8484
"unicorn/filename-case": "warn",
8585
"unicorn/prefer-query-selector": "error"
8686
}

src/main/zapHomeFiles/hud/display.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ Vue.component('site-tree-node', {
754754
if ((name.match(/\//g) || []).length > 2) {
755755
// If there are more than 2 slashes just show last url element
756756
// The first 2 slashes will be http(s)://...
757-
name = name.substring(name.lastIndexOf('/') + 1);
757+
name = name.slice(name.lastIndexOf('/') + 1);
758758
}
759759

760760
if (isLeaf) {

src/main/zapHomeFiles/hud/target/inject.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const injection = (function () {
3333
const r = Math.floor(Math.random() * 1000);
3434
const tabId = String(millis) + '-' + r;
3535

36-
return tabId.substring(6);
36+
return tabId.slice(6);
3737
}
3838

3939
/* TARGET INTERACTIONS */
@@ -623,8 +623,8 @@ const injection = (function () {
623623
if (zapReplaceOffset > 0) {
624624
// Hide the zapHudReplaceReq injected when resending a message in the browser
625625
// But don't loose any fragment
626-
const fragment = window.location.hash.substr(1);
627-
let origUrl = window.location.href.substring(0, zapReplaceOffset - 1);
626+
const fragment = window.location.hash.slice(1);
627+
let origUrl = window.location.href.slice(0, zapReplaceOffset - 1);
628628
if (fragment) {
629629
origUrl += '#' + fragment;
630630
}

src/main/zapHomeFiles/hud/tools/commonAlerts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const CommonAlerts = (function () {
8585
if (zapReplaceOffset > 0) {
8686
// Strip off the string used for resending in the browser
8787
// Will be preceded by ? or &
88-
origTarget = origTarget.substring(0, zapReplaceOffset - 1);
88+
origTarget = origTarget.slice(0, zapReplaceOffset - 1);
8989
}
9090

9191
let target = origTarget;

src/main/zapHomeFiles/hud/tools/utils/alertUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const alertUtils = (function () {
7070

7171
if (target.indexOf('?') > 0) {
7272
// Remove any url params
73-
target = target.substring(0, target.indexOf('?'));
73+
target = target.slice(0, target.indexOf('?'));
7474
}
7575

7676
return apiCallWithResponse('alert', 'view', 'alertsByRisk', {url: target, recurse: 'false'});

src/main/zapHomeFiles/hud/utils.js

Lines changed: 24 additions & 24 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.substring(0, headerText.indexOf(' '));
47-
headerText = headerText.substring(headerText.indexOf(' ') + 1);
46+
header.method = headerText.slice(0, headerText.indexOf(' '));
47+
headerText = headerText.slice(headerText.indexOf(' ') + 1);
4848

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

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

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

6161
if (!headerText.includes('\n')) {
6262
value = headerText;
6363
headerText = '';
6464
} else {
65-
value = headerText.substring(0, headerText.indexOf('\n'));
66-
headerText = headerText.substring(headerText.indexOf('\n') + 1);
65+
value = headerText.slice(0, headerText.indexOf('\n'));
66+
headerText = headerText.slice(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.substring(0, headerText.indexOf(' '));
82-
headerText = headerText.substring(headerText.indexOf(' ') + 1);
81+
header.version = headerText.slice(0, headerText.indexOf(' '));
82+
headerText = headerText.slice(headerText.indexOf(' ') + 1);
8383

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

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

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

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

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

139-
return url.substring(start, end);
139+
return url.slice(start, end);
140140
}
141141

142142
/* STORAGE */
@@ -650,7 +650,7 @@ const utils = (function () {
650650
scheme = 'http';
651651
}
652652

653-
return scheme + '://' + domain + url.substring(url.indexOf(domain) + domain.length);
653+
return scheme + '://' + domain + url.slice(url.indexOf(domain) + domain.length);
654654
})
655655
.catch(errorHandler);
656656
}
@@ -665,8 +665,8 @@ const utils = (function () {
665665
// Construct the stack trace
666666
const lines = error.stack.split('\n').slice(0, -1);
667667
lines.forEach(line => {
668-
const functionName = line.substring(0, line.indexOf('/'));
669-
const urlAndLineNo = line.substring(line.indexOf('http'), line.length - 1);
668+
const functionName = line.slice(0, line.indexOf('/'));
669+
const urlAndLineNo = line.slice(line.indexOf('http'), -1);
670670
const parts = urlAndLineNo.split(':');
671671
let url = parts[0] + ':' + parts[1];
672672
let lineNo = parts[2] + ':' + parts[3];

0 commit comments

Comments
 (0)