(input: Uint8Array | string)
| 31 | |
| 32 | /** Encodes an input using Base64URL with no padding. */ |
| 33 | export function encode(input: Uint8Array | string): string { |
| 34 | let unencoded = input |
| 35 | if (typeof unencoded === 'string') { |
| 36 | unencoded = encoder.encode(unencoded) |
| 37 | } |
| 38 | |
| 39 | // @ts-ignore |
| 40 | if (Uint8Array.prototype.toBase64) { |
| 41 | // @ts-ignore |
| 42 | return unencoded.toBase64({ alphabet: 'base64url', omitPadding: true }) |
| 43 | } |
| 44 | |
| 45 | return encodeBase64(unencoded).replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_') |
| 46 | } |
no test coverage detected
searching dependent graphs…