Skip to content

Instantly share code, notes, and snippets.

@nichoth
Last active November 14, 2025 20:48
Show Gist options
  • Select an option

  • Save nichoth/65a4c3cfa93adaf46ac5b2db4c26467e to your computer and use it in GitHub Desktop.

Select an option

Save nichoth/65a4c3cfa93adaf46ac5b2db4c26467e to your computer and use it in GitHub Desktop.
Base64 tricks
function fromUrlEncoded (base64url:string):Record<string, any> {
const base64Url = token.split('.')[1];
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
return JSON.parse(atob(base64));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment