Skip to content

Commit

Permalink
fix: handle empty string for PROXY_HOST and PROXY_PORT (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
aneeshrelan committed Sep 30, 2021
1 parent bb5dde7 commit cce2462
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as tunnel from "tunnel";
const { PROXY_HOST, PROXY_PORT, PROXY_USERNAME, PROXY_PASSWORD } = process.env;

const isProxyDefined = (): boolean => {
return PROXY_HOST !== undefined && PROXY_PORT !== undefined;
return !!PROXY_HOST && !!PROXY_PORT;
};

const getProxyAuth = (): string | undefined => {
Expand Down
10 changes: 10 additions & 0 deletions tests/praxios.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,14 @@ describe("praxios", () => {

expect(praxios.defaults.httpsAgent.proxyOptions.localAddress).toBeUndefined();
});

test("empty string for proxy host options are assumed as proxy not being set", async () => {
process.env.PROXY_HOST = "";
process.env.PROXY_PORT = "";

const praxios = (await import("../src/index")).default;

expect(praxios.defaults.httpsAgent).toBeUndefined();
expect(praxios.defaults.proxy).toBeUndefined();
});
});

0 comments on commit cce2462

Please sign in to comment.