Skip to content

Commit

Permalink
squash: simplify copying from ArrayBufferView
Browse files Browse the repository at this point in the history
  • Loading branch information
LiviaMedeiros committed May 28, 2022
1 parent bfcb4f4 commit 2b328c8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
4 changes: 1 addition & 3 deletions lib/tls.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,7 @@ exports.convertALPNProtocols = function convertALPNProtocols(protocols, out) {
// Copy new buffer not to be modified by user.
out.ALPNProtocols = Buffer.from(protocols);
} else if (isArrayBufferView(protocols)) {
out.ALPNProtocols = Buffer.from(protocols.buffer.slice(),
protocols.byteOffset,
protocols.byteLength);
out.ALPNProtocols = Buffer.from(protocols.slice().buffer);
}
};

Expand Down
5 changes: 1 addition & 4 deletions test/parallel/test-tls-basic-validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,8 @@ assert.throws(
const inputBuffer = Buffer.from(arrayBufferViewStr.repeat(8), 'utf8');
for (const expectView of common.getArrayBufferViews(inputBuffer)) {
const out = {};
const expected = Buffer.from(expectView.buffer.slice(),
expectView.byteOffset,
expectView.byteLength);
tls.convertALPNProtocols(expectView, out);
assert(out.ALPNProtocols.equals(expected));
assert(out.ALPNProtocols.equals(Buffer.from(expectView.slice().buffer)));
}
}

Expand Down

0 comments on commit 2b328c8

Please sign in to comment.