Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for issue #55 #56

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/utilities/parseProxyUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ export default (url: string) => {
throw new UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL must not have hash.');
}

if (urlTokens.protocol !== 'http:') {
throw new UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL protocol must be "http:".');
if (urlTokens.protocol !== 'http:' && urlTokens.protocol !== '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
Original file line number Diff line number Diff line change
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