Skip to content

Commit

Permalink
Check for NativeBuffer in ed25519#messageToNativeBuffer
Browse files Browse the repository at this point in the history
While this technically is not necessary, because node.js' Buffer
inherits from Uint8Array this contract is broken by jest.
See jestjs/jest#4422.

Add a `message instanceof NativeBuffer` to the function to fix the issue,
it does no harm and *technically* would be the more correct check, because
for node.js passing a raw Uint8Array does not return a Buffer.
  • Loading branch information
TimWolla committed Jul 23, 2019
1 parent 7e833b9 commit 220c78e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ed25519.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ ed25519.verify = function(options) {

function messageToNativeBuffer(options) {
var message = options.message;
if(message instanceof Uint8Array) {
if(message instanceof Uint8Array || message instanceof NativeBuffer) {
return message;
}

Expand Down

0 comments on commit 220c78e

Please sign in to comment.