1 | /** |
2 | * @param { string } base64String |
3 | */ |
4 | export function urlBase64ToUint8Array(base64String) { |
5 | const padding = "=".repeat((4 - (base64String.length % 4)) % 4) |
6 | const base64 = (base64String + padding).replace(/\-/g, '+').replace(/_/g, '/') |
7 | const rawData = atob(base64) |
8 | const outputArray = new Uint8Array(rawData.length) |
9 | for (let i = 0; i < rawData.length; ++i) { |
10 | outputArray[i] = rawData.charCodeAt(i) |
11 | } |
12 | return outputArray |
13 | } |