Skip to content

Commit

Permalink
utils/fetch: support options.agent being a boolean.
Browse files Browse the repository at this point in the history
node-fetch/node-fetch#1502 changed the type of
options.agent to allow a boolean, which caused issues as we tried to call
it.  Flip the condition around and check for function instead, so that this
compiles.

Signed-off-by: Mark Yen <mark.yen@suse.com>
  • Loading branch information
mook-as committed May 31, 2022
1 parent 64ff771 commit 08fae06
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/utils/fetch.ts
Expand Up @@ -113,10 +113,10 @@ export default async function fetch(url: string, options?: RequestInit) {
let agent: http.Agent;

if (options?.agent) {
if (options.agent instanceof http.Agent) {
agent = options.agent;
} else {
if (typeof options.agent === 'function') {
agent = options.agent(parsedURL);
} else {
agent = options.agent;
}
} else {
agent = isSecure ? https.globalAgent : http.globalAgent;
Expand Down

0 comments on commit 08fae06

Please sign in to comment.