Skip to content

Commit 9fa9e68

Browse files
authored
Update idUtils.ts to allow integer IDs
1 parent 013171f commit 9fa9e68

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/cma-client/src/idUtils.ts

+7
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ function fromUrlSafeBase64toUint8Array(urlSafeBase64: string): Uint8Array {
3434
}
3535

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

3946
// UUIDs are 16 bytes

0 commit comments

Comments
 (0)