Skip to content
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

Update substr calls to substring #4276

Merged
merged 2 commits into from
May 31, 2022
Merged

Update substr calls to substring #4276

merged 2 commits into from
May 31, 2022

Conversation

willeastcott
Copy link
Contributor

Fixes #4252

I confirm I have read the contributing guidelines and signed the Contributor License Agreement.

@willeastcott willeastcott self-assigned this May 26, 2022
@willeastcott willeastcott changed the title Update substr calls to substring Update substr calls to substring May 26, 2022
Comment on lines +26 to +28
defineProtoFunc(String, 'startsWith', function(search, rawPos) {
var pos = rawPos > 0 ? rawPos|0 : 0;
return this.substring(pos, pos + search.length) === search;
Copy link
Collaborator

@kungfooman kungfooman May 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
defineProtoFunc(String, 'startsWith', function(search, rawPos) {
var pos = rawPos > 0 ? rawPos|0 : 0;
return this.substring(pos, pos + search.length) === search;
defineProtoFunc(String, 'startsWith', function(search, pos) {
pos = pos > 0 ? pos|0 : 0;
return this.substring(pos, pos + search.length) === search;

(removing var while reusing pos variable)

Copy link
Contributor Author

@willeastcott willeastcott May 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this code can be tweaked but I'm just updating what's here to the linked Polyfill on MDN. I'd rather keep this in sync with that.

Copy link
Contributor

@mvaligursky mvaligursky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

@willeastcott willeastcott merged commit f6ec317 into main May 31, 2022
@willeastcott willeastcott deleted the substr-to-substring branch May 31, 2022 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove uses of deprecated function string.substr()
3 participants