From b73de74ea357326ddebbef94a903c8cdd681d8e5 Mon Sep 17 00:00:00 2001 From: JspIIV Date: Sun, 23 Aug 2026 01:56:43 +0300 Subject: [PATCH] fix(config): keep '=' inside the value of config set keyValue.split("=") destructures only the first two parts, so a value containing "=" was silently truncated at the first one. base64 padding and URLs with a query string are the common cases: config set apiKey=YWJjZGVm== stored YWJjZGVm config set rpcUrl=https://x/v1?key=a&m=fast stored https://x/v1?key Splits on the first separator instead. An empty value and a missing separator behave as before. --- src/commands/config/getSetReset.ts | 7 ++++++- tests/actions/getSetReset.test.ts | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/commands/config/getSetReset.ts b/src/commands/config/getSetReset.ts index b7499316..3f45e6f2 100644 --- a/src/commands/config/getSetReset.ts +++ b/src/commands/config/getSetReset.ts @@ -7,7 +7,12 @@ export class ConfigActions extends BaseAction { } set(keyValue: string): void { - const [key, value] = keyValue.split("="); + // Split on the first "=" only. Config values legitimately contain "=" — + // base64 padding, URLs with a query string — and splitting on every one + // silently stored a truncated value. + const separatorIndex = keyValue.indexOf("="); + const key = separatorIndex === -1 ? "" : keyValue.slice(0, separatorIndex); + const value = separatorIndex === -1 ? undefined : keyValue.slice(separatorIndex + 1); this.startSpinner(`Updating configuration: ${key}`); if (!key || value === undefined) { diff --git a/tests/actions/getSetReset.test.ts b/tests/actions/getSetReset.test.ts index fb0ded72..33cf2833 100644 --- a/tests/actions/getSetReset.test.ts +++ b/tests/actions/getSetReset.test.ts @@ -28,6 +28,27 @@ describe("ConfigActions", () => { expect(configActions["succeedSpinner"]).toHaveBeenCalledWith("Configuration successfully updated"); }); + test("set method keeps '=' inside the value", () => { + configActions.set("apiKey=YWJjZGVm=="); + + expect(configActions["writeConfig"]).toHaveBeenCalledWith("apiKey", "YWJjZGVm=="); + }); + + test("set method keeps a query string intact", () => { + configActions.set("rpcUrl=https://rpc.example.com/v1?key=abc&mode=fast"); + + expect(configActions["writeConfig"]).toHaveBeenCalledWith( + "rpcUrl", + "https://rpc.example.com/v1?key=abc&mode=fast", + ); + }); + + test("set method accepts an empty value", () => { + configActions.set("defaultNetwork="); + + expect(configActions["writeConfig"]).toHaveBeenCalledWith("defaultNetwork", ""); + }); + test("set method fails for invalid format", () => { configActions.set("invalidFormat");