From d09a0b2170c3f93319a5ce0984f57f12794617ca Mon Sep 17 00:00:00 2001 From: Nathalie Casati Date: Mon, 25 Mar 2024 15:56:49 +0000 Subject: [PATCH] fix: do not convert u8a to string if it's already a string --- html5/js/lib/rencode.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/html5/js/lib/rencode.js b/html5/js/lib/rencode.js index 23e82807..ac6321fb 100644 --- a/html5/js/lib/rencode.js +++ b/html5/js/lib/rencode.js @@ -301,6 +301,10 @@ function rdecode_string(dec) { return utf8ByteArrayToString(bytes) } function Uint8ToString(u8a){ + if (typeof u8a == "string") { + return u8a; + } + const CHUNK_SZ = 0x8000; const c = []; for (let i=0; i < u8a.length; i+=CHUNK_SZ) {