From 4c29320e4ed7ed042cff9d5111ec7b1555c274aa Mon Sep 17 00:00:00 2001 From: uNetworkingAB <110806833+uNetworkingAB@users.noreply.github.com> Date: Mon, 19 Aug 2024 13:34:01 +0200 Subject: [PATCH] Accept String & ArrayBuffer in DeclarativeResponse --- src/uws.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uws.js b/src/uws.js index fac660b9..0eccec16 100644 --- a/src/uws.js +++ b/src/uws.js @@ -32,7 +32,7 @@ module.exports.DeclarativeResponse = class DeclarativeResponse { _appendInstruction(opcode, ...text) { this.instructions.push(opcode); text.forEach(str => { - const bytes = new TextEncoder().encode(str); + const bytes = (typeof data === 'string') ? new TextEncoder().encode(str) : str; this.instructions.push(bytes.length, ...bytes); }); }