You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently if you try to pass an invalid hex value as an ID, e.g. if you pass fieldIds: [ 'shhh' ] then encode and decode will work without error, but you will get back an empty string: fieldIds: [ '' ]. This is because Buffer.from('shhh', 'hex') returns an empty Buffer.
I think it makes sense to throw if any of these id fields is invalid. We should do:
functionidBufferFromHex(idString){constbuf=Buffer.from(idString,hex)if(buf.length!==32)thrownewError('invalid id, must be 32-bytes encoded as hex string')returnbuf
The text was updated successfully, but these errors were encountered:
We might want a looser check here. We should definitely check for an empty string, and a string that encodes to an empty Buffer, but do we want more than that. Maybe buf.length >=8 to ensure that we have some degree of uniqueness?
Currently if you try to pass an invalid hex value as an ID, e.g. if you pass
fieldIds: [ 'shhh' ]
then encode and decode will work without error, but you will get back an empty string:fieldIds: [ '' ]
. This is becauseBuffer.from('shhh', 'hex')
returns an empty Buffer.I think it makes sense to throw if any of these id fields is invalid. We should do:
The text was updated successfully, but these errors were encountered: