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

Optimized strings prefix judge: use startsWith instead of substring #3691

Closed
wants to merge 1 commit into from

Conversation

BoynChan
Copy link

startsWith() can show stronger semantics than substring, it tells that this method is to judge if a string starts with some substring.

@ricmoo ricmoo added the on-deck This Enhancement or Bug is currently being worked on. label Feb 3, 2023
@ricmoo ricmoo added the v6 Issues regarding v6 label Feb 18, 2023
@@ -96,7 +96,7 @@ function getAccount(data: any, _key: string): KeystoreAccount {
const address = computeAddress(privateKey);
if (data.address) {
let check = data.address.toLowerCase();
if (check.substring(0, 2) !== "0x") { check = "0x" + check; }
if (check.startsWith("0x")) { check = "0x" + check; }
Copy link
Member

Choose a reason for hiding this comment

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

This should be prefixed with !. But no worries, I caught it during merging. Just adding here for future observers. ;)

Thanks! :)

@ricmoo
Copy link
Member

ricmoo commented Feb 19, 2023

Merged into v6.0.5.

Thanks! :)

@ricmoo ricmoo closed this Feb 19, 2023
@ricmoo ricmoo added fixed/complete This Bug is fixed or Enhancement is complete and published. and removed on-deck This Enhancement or Bug is currently being worked on. labels Feb 23, 2023
Woodpile37 pushed a commit to Woodpile37/ethers.js that referenced this pull request Jan 14, 2024
Woodpile37 pushed a commit to Woodpile37/ethers.js that referenced this pull request Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed/complete This Bug is fixed or Enhancement is complete and published. v6 Issues regarding v6
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants