From 892d59cbf899dfd4bfd99f7f61a86dfe4c981cea Mon Sep 17 00:00:00 2001 From: Chris Dickinson Date: Mon, 15 Jul 2024 13:05:27 -0700 Subject: [PATCH] fix: encode strings (even empty strings) when stored This fixes a bug where `CallContext.store('')` would throw an error. --- src/call-context.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/call-context.ts b/src/call-context.ts index a032308..d2f028e 100644 --- a/src/call-context.ts +++ b/src/call-context.ts @@ -451,14 +451,14 @@ export class CallContext { /** @hidden */ [STORE](input?: string | Uint8Array): number | null { - if (!input) { - return null; - } - if (typeof input === 'string') { input = this.#encoder.encode(input); } + if (!input) { + return null; + } + if (input instanceof Uint8Array) { if (input.buffer.constructor === this.#arrayBufferType) { // no action necessary, wrap it up in a block