From 08fc8d50e35a27835d497a631a6dcc0f733546de Mon Sep 17 00:00:00 2001 From: Jovi De Croock Date: Sun, 31 Dec 2023 12:50:37 +0100 Subject: fix(node/zlib): cast Dataview and Buffer to uint8 (#21746) This fixes point 2 of #20516 This adds a conversion from Dataview/Buffer by returning `obj.buffer` which can be converted to a `UInt8Array`. Question: Regarding point 4 of the mentioned issue would it be appropriate to copy the toU8 helper to the `zlib.mjs` methods? --- ext/node/polyfills/_brotli.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'ext') diff --git a/ext/node/polyfills/_brotli.js b/ext/node/polyfills/_brotli.js index bf099759b..cd54eedda 100644 --- a/ext/node/polyfills/_brotli.js +++ b/ext/node/polyfills/_brotli.js @@ -19,6 +19,10 @@ const toU8 = (input) => { return enc.encode(input); } + if (input.buffer) { + return new Uint8Array(input.buffer); + } + return input; }; -- cgit v1.2.3