Skip to content

Commit 00b669c

Browse files
committed
fix(protocol): decode "*-1" correctly
1 parent 06ec545 commit 00b669c

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## v3.0.3
44

55
- fix(command): Return keys in `HMGET` command correctly.
6+
- fix(protocol): decode `*-1` correctly
67

78
## v3.0.2
89

src/lib/Decoder.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -234,24 +234,32 @@ export class Decoder extends EventEmitter implements C.IDecoder {
234234

235235
if (end > -1) {
236236

237-
this._ctx.type = C.EDataType.LIST;
238-
239-
this._ctx.value = [];
240-
241237
this._ctx.data.length = parseInt(this._buf.subarray(
242238
this._ctx.pos,
243239
end
244240
).toString());
245241

246-
if (this._ctx.data.length === 0 || this._ctx.data.length === -1) {
242+
if (this._ctx.data.length === -1) {
247243

244+
this._ctx.type = C.EDataType.NULL;
245+
this._ctx.value = null;
248246
this._pop(end + 2);
249247
}
250248
else {
251249

252-
this._cut(end + 2);
253-
this._ctx.pos = this._cursor;
254-
this._ctx.status = EDecodeStatus.READING_LIST;
250+
this._ctx.type = C.EDataType.LIST;
251+
this._ctx.value = [];
252+
253+
if (this._ctx.data.length === 0) {
254+
255+
this._pop(end + 2);
256+
}
257+
else {
258+
259+
this._cut(end + 2);
260+
this._ctx.pos = this._cursor;
261+
this._ctx.status = EDecodeStatus.READING_LIST;
262+
}
255263
}
256264
}
257265
else {

0 commit comments

Comments
 (0)