Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ef6a210

Browse filesBrowse files
Jungku Leetargos
authored andcommitted
url,tools,benchmark: replace deprecated substr()
PR-URL: #51546 Refs: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/String/substr Reviewed-By: Jithil P Ponnan <jithil@outlook.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent e016e95 commit ef6a210
Copy full SHA for ef6a210

File tree

Expand file treeCollapse file tree

5 files changed

+10
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

5 files changed

+10
-6
lines changed
Open diff view settings
Collapse file

‎.eslintrc.js‎

Copy file name to clipboardExpand all lines: .eslintrc.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ module.exports = {
212212
selector: 'ThrowStatement > CallExpression[callee.name=/Error$/]',
213213
message: 'Use `new` keyword when throwing an `Error`.',
214214
},
215+
{
216+
selector: "CallExpression[callee.property.name='substr']",
217+
message: 'Use String.prototype.slice() or String.prototype.substring() instead of String.prototype.substr()',
218+
},
215219
{
216220
selector: "CallExpression[callee.name='isNaN']",
217221
message: 'Use Number.isNaN() instead of the global isNaN() function.',
Collapse file

‎benchmark/http/bench-parser.js‎

Copy file name to clipboardExpand all lines: benchmark/http/bench-parser.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function main({ len, n }) {
4646
let header = `GET /hello HTTP/1.1${CRLF}Content-Type: text/plain${CRLF}`;
4747

4848
for (let i = 0; i < len; i++) {
49-
header += `X-Filler${i}: ${Math.random().toString(36).substr(2)}${CRLF}`;
49+
header += `X-Filler${i}: ${Math.random().toString(36).substring(2)}${CRLF}`;
5050
}
5151
header += CRLF;
5252

Collapse file

‎lib/url.js‎

Copy file name to clipboardExpand all lines: lib/url.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ Url.prototype.resolveObject = function resolveObject(relative) {
958958
srcPath.unshift('');
959959
}
960960

961-
if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
961+
if (hasTrailingSlash && (srcPath.join('/').slice(-1) !== '/')) {
962962
srcPath.push('');
963963
}
964964

Collapse file

‎tools/doc/html.mjs‎

Copy file name to clipboardExpand all lines: tools/doc/html.mjs
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,8 @@ function versionSort(a, b) {
394394
b = minVersion(b).trim();
395395
let i = 0; // Common prefix length.
396396
while (i < a.length && i < b.length && a[i] === b[i]) i++;
397-
a = a.substr(i);
398-
b = b.substr(i);
397+
a = a.substring(i);
398+
b = b.substring(i);
399399
return +b.match(numberRe)[0] - +a.match(numberRe)[0];
400400
}
401401

Collapse file

‎tools/doc/json.mjs‎

Copy file name to clipboardExpand all lines: tools/doc/json.mjs
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,8 @@ function parseSignature(text, sig) {
320320

321321
const eq = sigParam.indexOf('=');
322322
if (eq !== -1) {
323-
defaultValue = sigParam.substr(eq + 1);
324-
sigParam = sigParam.substr(0, eq);
323+
defaultValue = sigParam.substring(eq + 1);
324+
sigParam = sigParam.substring(0, eq);
325325
}
326326

327327
// At this point, the name should match. If it doesn't find one that does.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.