(value: string)
| 6 | * Pure function. Tested in the sibling `.test.ts`. |
| 7 | */ |
| 8 | export 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 | } |
no outgoing calls
no test coverage detected