Skip to content

Commit 50a87ed

Browse files
author
Chris Gu
committed
fix for issue gajus#55
1 parent bf4aa36 commit 50a87ed

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/utilities/parseProxyUrl.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export default (url: string) => {
1414
}
1515

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

2021
let port = 80;

test/global-agent/utilities/parseProxyUrl.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ test('extracts authorization', (t) => {
1313
t.is(parseProxyUrl('http://foo:[email protected]').authorization, 'foo:bar');
1414
});
1515

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

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

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

0 commit comments

Comments
 (0)