GeezerVison is showing github.com — url,tools,benchmark: replace deprecated `substr()` · nodejs/node@ef6a210
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: .eslintrc.js +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -212,6 +212,10 @@ module.exports = { |
212 | 212 | selector: 'ThrowStatement > CallExpression[callee.name=/Error$/]', |
213 | 213 | message: 'Use `new` keyword when throwing an `Error`.', |
214 | 214 | }, |
| 215 | + { |
| 216 | + selector: "CallExpression[callee.property.name='substr']", |
| 217 | + message: 'Use String.prototype.slice() or String.prototype.substring() instead of String.prototype.substr()', |
| 218 | + }, |
215 | 219 | { |
216 | 220 | selector: "CallExpression[callee.name='isNaN']", |
217 | 221 | message: 'Use Number.isNaN() instead of the global isNaN() function.', |
|
Collapse file
Copy file name to clipboardExpand all lines: benchmark/http/bench-parser.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -46,7 +46,7 @@ function main({ len, n }) { |
46 | 46 | let header = `GET /hello HTTP/1.1${CRLF}Content-Type: text/plain${CRLF}`; |
47 | 47 |
|
48 | 48 | 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}`; |
50 | 50 | } |
51 | 51 | header += CRLF; |
52 | 52 |
|
|
Collapse file
Copy file name to clipboardExpand all lines: lib/url.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -958,7 +958,7 @@ Url.prototype.resolveObject = function resolveObject(relative) { |
958 | 958 | srcPath.unshift(''); |
959 | 959 | } |
960 | 960 |
|
961 | | - if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) { |
| 961 | + if (hasTrailingSlash && (srcPath.join('/').slice(-1) !== '/')) { |
962 | 962 | srcPath.push(''); |
963 | 963 | } |
964 | 964 |
|
|
Collapse file
Copy file name to clipboardExpand all lines: tools/doc/html.mjs +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -394,8 +394,8 @@ function versionSort(a, b) { |
394 | 394 | b = minVersion(b).trim(); |
395 | 395 | let i = 0; // Common prefix length. |
396 | 396 | 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); |
399 | 399 | return +b.match(numberRe)[0] - +a.match(numberRe)[0]; |
400 | 400 | } |
401 | 401 |
|
|
Collapse file
Copy file name to clipboardExpand all lines: tools/doc/json.mjs +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -320,8 +320,8 @@ function parseSignature(text, sig) { |
320 | 320 |
|
321 | 321 | const eq = sigParam.indexOf('='); |
322 | 322 | 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); |
325 | 325 | } |
326 | 326 |
|
327 | 327 | // At this point, the name should match. If it doesn't find one that does. |
|