Closed
Description
- Version: Node v6.5.0
- Platform: OS X 10.11
- Subsystem: Buffer
Buffer.from
silently ignores decoding errors.
Buffer.from('aGVsbG8=', 'base64') // valid base64 string
// => hello
Buffer.from('aGV sbG8=', 'base64') // invalid base64 string
// => hello
I know this is now the expected behavior but it would be useful, e.g. when writing parsers for strict protocols, to have a Buffer.safeFrom
which throws on decoding errors. It could also be passed as a parameter, e.g.: Buffer.from(str, [encoding, throwOnError])
.