Skip to content

Commit

Permalink
fix(json-pack): 🐛 allow emojis in strings
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Dec 10, 2023
1 parent 94f7441 commit a9744dd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/json-pack/resp/RespEncoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export class RespEncoder<W extends IWriter & IWriterGrowable = IWriter & IWriter
(encoding.charCodeAt(2) << 8) + // t
58, // :
);
writer.ascii(str);
writer.utf8(str);
writer.u16(RESP.RN); // \r\n
}

Expand Down
11 changes: 4 additions & 7 deletions src/json-pack/resp/__tests__/RespDecoder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@ const assertCodec = (value: unknown, expected: unknown = value): void => {

describe('strings', () => {
describe('simple strings', () => {
test('empty string', () => {
assertCodec('');
});

test('short string', () => {
assertCodec('foo bar');
});
test('empty string', () => assertCodec(''));
test('short string', () => assertCodec('foo bar'));
test('short string with emoji', () => assertCodec('foo bar🍼'));
test('short string with emoji and newline', () => assertCodec('foo bar\n🍼'));

test('simple string with newline', () => {
assertCodec('foo\nbar');
Expand Down

0 comments on commit a9744dd

Please sign in to comment.