Skip to content

Commit

Permalink
fix: callback route fails when state is "null" (#24)
Browse files Browse the repository at this point in the history
* fix: callback route fails when state is "null"

JSON.parse(atob("null")) throws

```
VM335:1 Uncaught SyntaxError: Unexpected token '�', "�ée" is not valid JSON
    at JSON.parse (<anonymous>)
    at <anonymous>:1:6
```

* format: match repo prettier
  • Loading branch information
ryanvanoss authored Oct 21, 2024
1 parent e5e636a commit 1301028
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/authkit-callback-route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function authLoader(options: HandleAuthOptions = {}) {

const code = url.searchParams.get('code');
const state = url.searchParams.get('state');
let returnPathname = state ? JSON.parse(atob(state)).returnPathname : null;
let returnPathname = state && stage !== 'null' ? JSON.parse(atob(state)).returnPathname : null;

if (code) {
try {
Expand Down

0 comments on commit 1301028

Please # to comment.