diff options
author | Satya Rohith <me@satyarohith.com> | 2024-11-06 19:42:24 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-06 15:12:24 +0100 |
commit | b3a3d84ce249ff126f92e7a0849ec0a6ce26e973 (patch) | |
tree | 34d09489a1c007c790e6ccff0f278ab59bd0c3ea /ext/node/polyfills/_zlib.mjs | |
parent | 700f54a13cce0fcdcf19d1893e3254579c7347f4 (diff) |
fix(node:zlib): gzip & gzipSync should accept ArrayBuffer (#26762)
Closes https://github.com/denoland/deno/issues/26638
Diffstat (limited to 'ext/node/polyfills/_zlib.mjs')
-rw-r--r-- | ext/node/polyfills/_zlib.mjs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/ext/node/polyfills/_zlib.mjs b/ext/node/polyfills/_zlib.mjs index 851bd602f..07fc440ef 100644 --- a/ext/node/polyfills/_zlib.mjs +++ b/ext/node/polyfills/_zlib.mjs @@ -14,6 +14,7 @@ import { nextTick } from "ext:deno_node/_next_tick.ts"; import { isAnyArrayBuffer, isArrayBufferView, + isUint8Array, } from "ext:deno_node/internal/util/types.ts"; var kRangeErrorMessage = "Cannot create final Buffer. It would be larger " + @@ -158,6 +159,12 @@ export const inflateRawSync = function (buffer, opts) { function sanitizeInput(input) { if (typeof input === "string") input = Buffer.from(input); + if (isArrayBufferView(input) && !isUint8Array(input)) { + input = Buffer.from(input.buffer, input.byteOffset, input.byteLength); + } else if (isAnyArrayBuffer(input)) { + input = Buffer.from(input); + } + if ( !Buffer.isBuffer(input) && (input.buffer && !input.buffer.constructor === ArrayBuffer) |