Skip to content

Commit

Permalink
Align whitespace between all files
Browse files Browse the repository at this point in the history
  • Loading branch information
jonkoops authored and frederikprijck committed Jul 29, 2023
1 parent 1d8b657 commit 68b244c
Show file tree
Hide file tree
Showing 8 changed files with 11,417 additions and 11,418 deletions.
56 changes: 28 additions & 28 deletions lib/base64_url_decode.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
function b64DecodeUnicode(str: string) {
return decodeURIComponent(
atob(str).replace(/(.)/g, function(m, p) {
let code = p.charCodeAt(0).toString(16).toUpperCase();
if (code.length < 2) {
code = "0" + code;
}
return "%" + code;
})
);
return decodeURIComponent(
atob(str).replace(/(.)/g, function(m, p) {
let code = p.charCodeAt(0).toString(16).toUpperCase();
if (code.length < 2) {
code = "0" + code;
}
return "%" + code;
})
);
}

export default function(str: string) {
let output = str.replace(/-/g, "+").replace(/_/g, "/");
switch (output.length % 4) {
case 0:
break;
case 2:
output += "==";
break;
case 3:
output += "=";
break;
default:
throw new Error("base64 string is not of the correct length");
}
let output = str.replace(/-/g, "+").replace(/_/g, "/");
switch (output.length % 4) {
case 0:
break;
case 2:
output += "==";
break;
case 3:
output += "=";
break;
default:
throw new Error("base64 string is not of the correct length");
}

try {
return b64DecodeUnicode(output);
} catch (err) {
return atob(output);
}
}
try {
return b64DecodeUnicode(output);
} catch (err) {
return atob(output);
}
}
2 changes: 1 addition & 1 deletion lib/index.cjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import jwtDecode, { InvalidTokenError } from "./index";
const wrapper = jwtDecode as any;
wrapper.default = jwtDecode;
wrapper.InvalidTokenError = InvalidTokenError;
export default wrapper;
export default wrapper;
2 changes: 1 addition & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ function jwtDecode(
}
}

export default jwtDecode;
export default jwtDecode;
Loading

0 comments on commit 68b244c

Please sign in to comment.