MCPcopy Create free account
hub / github.com/flatlogic/react-material-admin / decodeBase64Url

Function decodeBase64Url

src/utils/jwt.js:1–16  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

1function decodeBase64Url(value) {
2 const base64 = value.replace(/-/g, '+').replace(/_/g, '/');
3 const padded = base64 + '==='.slice((base64.length + 3) % 4);
4 const ascii = atob(padded);
5
6 try {
7 return decodeURIComponent(
8 ascii
9 .split('')
10 .map((char) => `%${(`00${char.charCodeAt(0).toString(16)}`).slice(-2)}`)
11 .join(''),
12 );
13 } catch {
14 return ascii;
15 }
16}
17
18export function decodeJwtPayload(token) {
19 if (!token || typeof token !== 'string') {

Callers 1

decodeJwtPayloadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected