MCPcopy
hub / github.com/panva/jose / encode

Function encode

src/util/base64url.ts:33–46  ·  view source on GitHub ↗
(input: Uint8Array | string)

Source from the content-addressed store, hash-verified

31
32/** Encodes an input using Base64URL with no padding. */
33export 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}

Callers 15

general.test.tsFile · 0.50
zip.test.tsFile · 0.50
unencoded.test.tsFile · 0.50
general.test.tsFile · 0.50
crit.test.tsFile · 0.50

Calls 2

encodeBase64Function · 0.85
encodeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…