Skip to content

Commit

Permalink
Update idUtils.ts to allow integer IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
arcataroger committed Jun 20, 2024
1 parent 013171f commit 9fa9e68
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/cma-client/src/idUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ function fromUrlSafeBase64toUint8Array(urlSafeBase64: string): Uint8Array {
}

export function isValidId(id: string) {
// For backward compatibility, first check to see if this is an older-style integer ID formerly used by Dato
if (/^\d+$/.test(id)) {
const intId = BigInt(id);
const maxDatoIntegerId = 281474976710655; // Max 6-byte/48-bit unsigned int
return intId <= maxDatoIntegerId;
}

const bytes = fromUrlSafeBase64toUint8Array(id);

// UUIDs are 16 bytes
Expand Down

0 comments on commit 9fa9e68

Please sign in to comment.