From f5291311f12e42106efd70c41f891493f5899fba Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sat, 7 Feb 2026 13:20:45 +0100 Subject: [PATCH] Simplify base64 cursor encoding to plain btoa/atob Signed-off-by: Patrik Oldsberg Co-authored-by: Cursor --- .../src/testUtils/InMemoryCatalogClient.ts | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/packages/catalog-client/src/testUtils/InMemoryCatalogClient.ts b/packages/catalog-client/src/testUtils/InMemoryCatalogClient.ts index 48111c96cf..a769f1996d 100644 --- a/packages/catalog-client/src/testUtils/InMemoryCatalogClient.ts +++ b/packages/catalog-client/src/testUtils/InMemoryCatalogClient.ts @@ -57,23 +57,12 @@ import type { } from '@backstage/plugin-catalog-common'; import { DEFAULT_STREAM_ENTITIES_LIMIT } from '../constants.ts'; -function base64Encode(str: string): string { - const bytes = new TextEncoder().encode(str); - return btoa(Array.from(bytes, b => String.fromCodePoint(b)).join('')); -} - -function base64Decode(str: string): string { - const bin = atob(str); - const bytes = Uint8Array.from(bin, c => c.codePointAt(0)!); - return new TextDecoder().decode(bytes); -} - function makeCursor(data: Record): string { - return base64Encode(JSON.stringify(data)); + return btoa(JSON.stringify(data)); } function parseCursor(cursor: string): Record { - return JSON.parse(base64Decode(cursor)); + return JSON.parse(atob(cursor)); } // CATALOG_FILTER_EXISTS is a Symbol that doesn't survive JSON serialization,