MCPcopy Create free account
hub / github.com/boringstack-xyz/boringstack / urlBase64ToUint8Array

Function urlBase64ToUint8Array

apps/ui/src/hooks/useWebPush.utils.ts:8–19  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

6 * Pure function. Tested in the sibling `.test.ts`.
7 */
8export function urlBase64ToUint8Array(value: string): Uint8Array {
9 const padding = "=".repeat((4 - (value.length % 4)) % 4);
10 const base64 = (value + padding).replace(/-/gu, "+").replace(/_/gu, "/");
11 const raw = atob(base64);
12 const output = new Uint8Array(raw.length);
13
14 for (let i = 0; i < raw.length; i += 1) {
15 output[i] = raw.charCodeAt(i);
16 }
17
18 return output;
19}

Callers 2

useWebPushFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected