MCPcopy Create free account
hub / github.com/ColmapView/Colmapview.github.io / toBase64Url

Function toBase64Url

src/utils/urlCameraStateCodec.ts:7–15  ·  view source on GitHub ↗
(bytes: Uint8Array)

Source from the content-addressed store, hash-verified

5 * Convert Uint8Array to Base64URL string (URL-safe, no padding).
6 */
7export function toBase64Url(bytes: Uint8Array): string {
8 const chunkSize = 0x8000;
9 const chunks: string[] = [];
10 for (let offset = 0; offset < bytes.length; offset += chunkSize) {
11 chunks.push(String.fromCharCode(...bytes.subarray(offset, offset + chunkSize)));
12 }
13 const base64 = btoa(chunks.join(''));
14 return base64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
15}
16
17/**
18 * Convert Base64URL string to Uint8Array.

Calls

no outgoing calls