Skip to content

Commit

Permalink
style: no anonymous function
Browse files Browse the repository at this point in the history
  • Loading branch information
victorforissier committed Mar 8, 2024
1 parent 161aa77 commit a4e139d
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions lib/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,23 @@ export async function getSession(

// cleanURLFromTokens removes access_token and refresh_token from the URL
// Required otherwise other useful link params are lost
const cleanURLFromTokens = () => {
const url = new URL(window.location.href);
if (url.hash.includes("access_token") || url.hash.includes("refresh_token")) {
const newHash = url.hash
.substring(1)
.split("&")
.filter(
(param) =>
!param.startsWith("access_token") &&
!param.startsWith("refresh_token"),
)
.join("&");

window.history.replaceState(
{},
window.document.title,
`${url.pathname}${url.search}${newHash ? `#${newHash}` : ""}`,
);
}
};
cleanURLFromTokens();
const url = new URL(window.location.href);
if (url.hash.includes("access_token") || url.hash.includes("refresh_token")) {
const newHash = url.hash
.substring(1)
.split("&")
.filter(
(param) =>
!param.startsWith("access_token") && !param.startsWith("refresh_token"),
)
.join("&");

window.history.replaceState(
{},
window.document.title,
`${url.pathname}${url.search}${newHash ? `#${newHash}` : ""}`,
);
}
}

if (!refreshToken) {
Expand Down

0 comments on commit a4e139d

Please sign in to comment.