Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align whitespace between all files #173

Merged
merged 1 commit into from
Jul 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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