Skip to content

Commit

Permalink
fix: Correctly decode Uint8Array
Browse files Browse the repository at this point in the history
  • Loading branch information
s12v committed May 27, 2024
1 parent ba8edb3 commit 617e82d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export async function coerceSdkv3Response(value: unknown): Promise<unknown> {
return value.toString('utf8');
}
if (ArrayBuffer.isView(value)) {
return decoder.decode(value.buffer);
return decoder.decode(value);
}

if (Array.isArray(value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ test.each([
{ transformToString: () => 'foo' },
Buffer.from('foo'),
new TextEncoder().encode('foo'),
new Uint8Array(new TextEncoder().encode('this is foo string').buffer, 8, 3),
])('coerce %p', async (fooValue) => {
expect(await coerceSdkv3Response({
foo: fooValue,
Expand Down

0 comments on commit 617e82d

Please sign in to comment.