Skip to content

Commit

Permalink
Fix headerToToken value check from null to undefined
Browse files Browse the repository at this point in the history
`headerToToken` returns `Promise<string | undefined>`. However, the existing
check assessed `headerToToken().then(value => value === null ? something
: somethingElse)`.
This should never be true.
Instead, this check is replaced with `!value`.
  • Loading branch information
thibmeu committed Jan 11, 2024
1 parent a3058b3 commit 49e764a
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export const handleHeadersReceived =
}
const redirectPromise = w3HeaderValue
.then(async (value): Promise<void | chrome.webRequest.BlockingResponse> => {
if (value === null) {
if (!value) {
delete TOKENS[details.url];
return;
}
Expand All @@ -307,9 +307,7 @@ export const handleHeadersReceived =
getAuthorizationRule(details.url, `PrivateToken token=${value}`),
);
} else {
if (value) {
TOKENS[details.url] = value;
}
TOKENS[details.url] = value;
}

return { redirectUrl: details.url };
Expand Down

0 comments on commit 49e764a

Please sign in to comment.