-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
url,tools,benchmark: replace deprecated substr()
#51546
Conversation
Review requested:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
If we are doing this, we should add a ESLint rule to avoid making the same decision over and over again. |
7242e8c
to
879629c
Compare
@anonrig Thank you for your good opinion. |
lib/url.js
Outdated
@@ -958,7 +958,8 @@ Url.prototype.resolveObject = function resolveObject(relative) { | |||
srcPath.unshift(''); | |||
} | |||
|
|||
if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) { | |||
const srcPathSlashes = srcPath.join('/'); | |||
if (hasTrailingSlash && (srcPathSlashes.substring(srcPathSlashes.length - 1) !== '/')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be srcPathSlashes.charAt(-1)
instead of srcPathSlashes.substring(srcPathSlashes.length - 1)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
srcPathSlashes.charAt(srcPathSlashes.length -1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
srcPathSlashes.charAt(srcPathSlashes.length -1)
hmm I mean sure... but .charAt(-1)
accomplishes the same result
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Err.. actually just .slice(-1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.charAt(-1)
works differently than before. I think .slice(-1)
is correct for this case. Thank you for your opinion.
I had divided the commits for review, but I will merge them into one and edit the First commit message. |
1b33e8a
to
07f751c
Compare
substr()
-> substring()
substr()
07f751c
to
094c72d
Compare
Landed in 78dbda1 |
PR-URL: #51546 Refs: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/String/substr Reviewed-By: Jithil P Ponnan <[email protected]> Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
PR-URL: #51546 Refs: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/String/substr Reviewed-By: Jithil P Ponnan <[email protected]> Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
PR-URL: #51546 Refs: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/String/substr Reviewed-By: Jithil P Ponnan <[email protected]> Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
PR-URL: #51546 Refs: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/String/substr Reviewed-By: Jithil P Ponnan <[email protected]> Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
PR-URL: nodejs#51546 Refs: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/String/substr Reviewed-By: Jithil P Ponnan <[email protected]> Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
PR-URL: nodejs#51546 Refs: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/String/substr Reviewed-By: Jithil P Ponnan <[email protected]> Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
Replace deprecated API.
Refs: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/String/substr