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

Function fromBase64Url

src/utils/urlCameraStateCodec.ts:20–36  ·  view source on GitHub ↗
(str: string)

Source from the content-addressed store, hash-verified

18 * Convert Base64URL string to Uint8Array.
19 */
20export function fromBase64Url(str: string): Uint8Array | null {
21 try {
22 let base64 = str.replace(/-/g, '+').replace(/_/g, '/');
23 while (base64.length % 4 !== 0) {
24 base64 += '=';
25 }
26
27 const binary = atob(base64);
28 const bytes = new Uint8Array(binary.length);
29 for (let i = 0; i < binary.length; i++) {
30 bytes[i] = binary.charCodeAt(i);
31 }
32 return bytes;
33 } catch {
34 return null;
35 }
36}
37
38/**
39 * Encode camera state to binary (72 bytes: 9 Float64 values).

Callers 4

decodeShareDataFunction · 0.90
decodeCameraStateBinaryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected