diff --git a/src/helper/websocket/index.test.ts b/src/helper/websocket/index.test.ts index 0e767788..55e6879d 100644 --- a/src/helper/websocket/index.test.ts +++ b/src/helper/websocket/index.test.ts @@ -89,7 +89,7 @@ describe('WSContext', () => { expect(nullURLWS.url).toBeNull() }) it('Should normalize message in send()', () => { - let data: string | ArrayBuffer | null = null + let data: string | ArrayBuffer | Uint8Array | null = null const wsContext = new WSContext({ // eslint-disable-next-line @typescript-eslint/no-unused-vars send(received, _options) { @@ -104,6 +104,6 @@ describe('WSContext', () => { expect(data).toBeInstanceOf(ArrayBuffer) wsContext.send(new Uint8Array(16)) - expect(data).toBeInstanceOf(ArrayBuffer) + expect(data).toBeInstanceOf(Uint8Array) }) }) diff --git a/src/helper/websocket/index.ts b/src/helper/websocket/index.ts index e40baa2d..9976fe18 100644 --- a/src/helper/websocket/index.ts +++ b/src/helper/websocket/index.ts @@ -68,10 +68,7 @@ export class WSContext { this.protocol = init.protocol ?? null } send(source: string | ArrayBuffer | Uint8Array, options?: SendOptions): void { - this.#init.send( - typeof source === 'string' ? source : source instanceof Uint8Array ? source.buffer : source, - options ?? {} - ) + this.#init.send(source, options ?? {}) } raw?: T binaryType: BinaryType = 'arraybuffer'