Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/adapters/cursor/call-id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export function decodeCursorCallId(id: string): string {
const decoded = Buffer.from(payload, "base64url").toString("utf8");
// Round-trip guard: only trust payloads our encoder could have produced.
if (Buffer.from(decoded, "utf8").toString("base64url") !== payload) return id;
if (!needsEncoding(decoded)) return id;
return decoded;
} catch {
return id;
Expand Down
6 changes: 6 additions & 0 deletions tests/cursor-call-id.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ describe("cursor call-id codec", () => {
expect(decodeCursorCallId("call_abc123")).toBe("call_abc123");
});

test("plain ids in the reserved namespace pass through unchanged", () => {
const id = "ocxc1_Y2FsbF8x";
expect(encodeCursorCallId(id)).toBe(id);
expect(decodeCursorCallId(id)).toBe(id);
});

test("newline composite id round-trips through a single-line form", () => {
const encoded = encodeCursorCallId(COMPOSITE);
expect(encoded).not.toContain("\n");
Expand Down
Loading