Skip to content

Commit

Permalink
fix for issue #55
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Gu committed Aug 6, 2022
1 parent bf4aa36 commit 50a87ed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/utilities/parseProxyUrl.ts
Expand Up @@ -14,7 +14,8 @@ export default (url: string) => {
}

if (urlTokens.protocol !== 'http:' && urlTokens.protocol !== 'https:') {
throw new UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` or `GLOBAL_AGENT.HTTPS_PROXY` configuration value: URL protocol must be "http:" or "https:".');
const errorMessage = 'Unsupported `GLOBAL_AGENT.HTTP_PROXY` or `GLOBAL_AGENT.HTTPS_PROXY` configuration value: URL protocol must be "http:" or "https:".';
throw new UnexpectedStateError(errorMessage);
}

let port = 80;
Expand Down
6 changes: 3 additions & 3 deletions test/global-agent/utilities/parseProxyUrl.ts
Expand Up @@ -13,12 +13,12 @@ test('extracts authorization', (t) => {
t.is(parseProxyUrl('http://foo:bar@0.0.0.0').authorization, 'foo:bar');
});

test('throws an error if protocol is not "http:"', (t) => {
test('throws an error if protocol is not "http:" or "https:"', (t) => {
const error = t.throws(() => {
parseProxyUrl('https://0.0.0.0:3000');
parseProxyUrl('ws://0.0.0.0:3000');
});

t.is(error.message, 'Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL protocol must be "http:".');
t.is(error.message, 'Unsupported `GLOBAL_AGENT.HTTP_PROXY` or `GLOBAL_AGENT.HTTPS_PROXY` configuration value: URL protocol must be "http:" or "https:".');
});

test('throws an error if query is present', (t) => {
Expand Down

0 comments on commit 50a87ed

Please sign in to comment.