Skip to content

Commit

Permalink
extractParams - handle invalid input
Browse files Browse the repository at this point in the history
  • Loading branch information
ovx committed Jul 25, 2024
1 parent acffb83 commit f500880
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cjs/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function extractParams(payload) {
if (typeof payload === 'string') {
payload = JSON.parse(atob(payload));
}
return Object.fromEntries(new URLSearchParams(payload.salt.split('?')?.[1] || ''));
return Object.fromEntries(new URLSearchParams(payload?.salt?.split('?')?.[1] || ''));
}
exports.extractParams = extractParams;
/**
Expand Down
2 changes: 1 addition & 1 deletion deno_dist/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function extractParams(payload: string | Payload | Challenge) {
payload = JSON.parse(atob(payload)) as Payload;
}
return Object.fromEntries(
new URLSearchParams(payload.salt.split('?')?.[1] || '')
new URLSearchParams(payload?.salt?.split('?')?.[1] || '')
);
}

Expand Down
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function extractParams(payload) {
if (typeof payload === 'string') {
payload = JSON.parse(atob(payload));
}
return Object.fromEntries(new URLSearchParams(payload.salt.split('?')?.[1] || ''));
return Object.fromEntries(new URLSearchParams(payload?.salt?.split('?')?.[1] || ''));
}
/**
* Verifies the solution provided by the client.
Expand Down
2 changes: 1 addition & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function extractParams(payload: string | Payload | Challenge) {
payload = JSON.parse(atob(payload)) as Payload;
}
return Object.fromEntries(
new URLSearchParams(payload.salt.split('?')?.[1] || '')
new URLSearchParams(payload?.salt?.split('?')?.[1] || '')
);
}

Expand Down

0 comments on commit f500880

Please sign in to comment.