Skip to content

Commit

Permalink
replace var with const
Browse files Browse the repository at this point in the history
  • Loading branch information
karannakra committed May 17, 2023
1 parent 72c3ec9 commit 0644237
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/jwt.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
export function parseJwt(token: string) {
var base64Url = token.split('.')[1];
const base64Url = token.split('.')[1];
if (!base64Url) {
return;
}
var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
var jsonPayload = decodeURIComponent(

const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
const jsonPayload = decodeURIComponent(
window
.atob(base64)
.split('')
Expand All @@ -18,6 +19,7 @@ export function parseJwt(token: string) {
if (typeof parsed === 'object' && parsed !== null) {
return parsed as Record<string, unknown>;
}

console.error('Could not parse JWT payload', parsed);
return;
} catch (e) {
Expand Down

0 comments on commit 0644237

Please sign in to comment.