Skip to content

Conversation

@adraffy
Copy link

@adraffy adraffy commented Mar 26, 2025

  • simplify hex regex

@ricmoo
Copy link
Member

ricmoo commented Mar 26, 2025

Interesting. Is it the non-capturing matching group that causes it to fail or the matching group in general?

Can you provide an example string (or just a length) for which the function fails? And the environment (browser vs node)?

@adraffy
Copy link
Author

adraffy commented Mar 26, 2025

Seems okay in node but:

$ bun --version
1.2.4
$ bun repl
> require('ethers').getBytes('0x'.padEnd(86014, '0'))
> require('ethers').getBytes('0x'.padEnd(86016, '0')) // error: invalid BytesLike value

It seems fixed now on 1.2.6?


It's still probably worth it to make the change:

  • !!'0x'.padEnd(3000000, '0').match(/^0x(?:[0-9a-f][0-9a-f])*$/i)false
  • !!'0x'.padEnd(3000000, '0').match(/^0x[0-9a-f]*$/)true
  • !!'0x'.padEnd(1000000000, '0').match(/^0x[0-9a-f]*$/)true

I encountered it parsing blobs.

@ricmoo ricmoo added enhancement New feature or improvement. on-deck This Enhancement or Bug is currently being worked on. v6 Issues regarding v6 next-patch Issues scheduled for the next arch release. labels Aug 19, 2025
@ricmoo
Copy link
Member

ricmoo commented Dec 3, 2025

Merged in v6.16.0. Thanks! :)

@ricmoo ricmoo closed this Dec 3, 2025
@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. next-patch Issues scheduled for the next arch release. labels Dec 3, 2025
@adraffy adraffy deleted the fix-getBytes branch December 3, 2025 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or improvement. 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