- Version: 10.16.3
- Platform: Darwin Renes-MacBook-Pro.local 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64
- Subsystem: Buffer
Run these in the REPL:
Buffer.from('0', 'hex').toString('hex') // returns ''
Buffer.from('08', 'hex').toString('hex') // returns '08'
Buffer.from('088', 'hex').toString('hex') // returns '08'
Buffer.from('0888', 'hex').toString('hex') // returns '0888'
Buffer.from('08888', 'hex').toString('hex') // returns '0888'
Buffer.from('088888', 'hex').toString('hex') // returns '088888'
I expected .toString('hex') to be the inverse operation of Buffer.from(x, 'hex'), but it doesn't seem to be the case. Why not?
I was able to catch this error using fast-check and it found a few other strings that behave this way: