File tree Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -226,6 +226,11 @@ describe('RESP Decoder', () => {
226226 toWrite : Buffer . from ( '+OK\r\n' ) ,
227227 replies : [ Buffer . from ( 'OK' ) ]
228228 } ) ;
229+
230+ test ( "'é'" , {
231+ toWrite : Buffer . from ( '+é\r\n' ) ,
232+ replies : [ 'é' ]
233+ } ) ;
229234 } ) ;
230235
231236 describe ( 'BlobString' , ( ) => {
@@ -251,6 +256,11 @@ describe('RESP Decoder', () => {
251256 toWrite : Buffer . from ( '$2\r\nOK\r\n' ) ,
252257 replies : [ Buffer . from ( 'OK' ) ]
253258 } ) ;
259+
260+ test ( "'é'" , {
261+ toWrite : Buffer . from ( '$2\r\né\r\n' ) ,
262+ replies : [ 'é' ]
263+ } ) ;
254264 } ) ;
255265
256266 describe ( 'VerbatimString' , ( ) => {
@@ -279,6 +289,11 @@ describe('RESP Decoder', () => {
279289 toWrite : Buffer . from ( '=6\r\ntxt:OK\r\n' ) ,
280290 replies : [ Buffer . from ( 'OK' ) ]
281291 } ) ;
292+
293+ test ( "'é'" , {
294+ toWrite : Buffer . from ( '=6\r\ntxt:é\r\n' ) ,
295+ replies : [ 'é' ]
296+ } ) ;
282297 } ) ;
283298
284299 test ( 'SimpleError' , {
Original file line number Diff line number Diff line change @@ -506,9 +506,8 @@ export class Decoder {
506506 }
507507
508508 chunks . push ( chunk . subarray ( start , crlfIndex ) ) ;
509- return type === Buffer ?
510- Buffer . concat ( chunks ) :
511- chunks . join ( '' ) ;
509+ const buffer = Buffer . concat ( chunks ) ;
510+ return type === Buffer ? buffer : buffer . toString ( ) ;
512511 }
513512
514513 #decodeBlobString( type , chunk ) {
@@ -578,9 +577,8 @@ export class Decoder {
578577
579578 chunks . push ( chunk . subarray ( this . #cursor, end ) ) ;
580579 this . #cursor = end + skip ;
581- return type === Buffer ?
582- Buffer . concat ( chunks ) :
583- chunks . join ( '' ) ;
580+ const buffer = Buffer . concat ( chunks ) ;
581+ return type === Buffer ? buffer : buffer . toString ( ) ;
584582 }
585583
586584 #decodeBlobStringWithLength( length , type , chunk ) {
You can’t perform that action at this time.
0 commit comments