Skip to content

Commit acf4faa

Browse files
committed
chore: release 0.1.4
1 parent 357faf2 commit acf4faa

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sloaix-node-bencode",
3-
"version": "0.1.3",
3+
"version": "0.1.4",
44
"description": "Bencode encoding and decoding, with both library and CLI versions available. The CLI version can decode bencode-formatted data from files or strings and output the result in JSON format.",
55
"keywords": [
66
"bencode",

src/encoder.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ export class Bencoder {
5656

5757
// 字符串的编码格式为:字符串的长度 + ':' + 字符串
5858
// 例如:4:spam
59-
return this.encoder.encode(`${byteString.toString().length}:${byteString}`)
59+
const buffers: Uint8Array[] = [this.encoder.encode(`${byteString.toString().length}:`)]
60+
61+
buffers.push(Buffer.from(byteString))
62+
63+
return Uint8Array.from(Buffer.concat(buffers))
6064
}
6165

6266
/**

0 commit comments

Comments
 (0)