Skip to content

Commit bf815bb

Browse files
committed
Throw error on empty options when creating server
1 parent 5b3a188 commit bf815bb

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

lib/proxyServer.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export interface ProxyTargetDetailed {
4242
ciphers?: string | undefined;
4343
secureProtocol?: string | undefined;
4444
}
45+
4546
export type ProxyTargetUrl = string | Partial<url.Url>;
4647

4748
export type ProxyTarget = ProxyTargetUrl | ProxyTargetDetailed;
@@ -126,6 +127,9 @@ export class ProxyServer extends EE3 {
126127

127128
constructor(options: ProxyServerOptions) {
128129
super();
130+
if (!options || Object.keys(options).length === 0) {
131+
throw new Error('Options must not be empty.');
132+
}
129133
options = options || {};
130134
options.prependPath = options.prependPath !== false;
131135

test/lib-http-proxy-passes-web-incoming-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ describe('#createProxy.web() using own http server', () => {
495495
});
496496

497497
it('should proxy requests to multiple servers with different options', async () => {
498-
const proxy = createProxy();
498+
const proxy = createProxy({target: 'http://ignored:8080'});
499499

500500
// proxies to two servers depending on url, rewriting the url as well
501501
// http://127.0.0.1:8080/s1/ -> http://127.0.0.1:8081/

test/lib-http-proxy-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Object.defineProperty(gen, 'port', {
2323

2424
describe('lib/http-proxy.js', () => {
2525
describe('#createProxy', () => {
26-
it.skip('should throw without options', function () {
26+
it('should throw without options', function () {
2727
let error;
2828
try {
2929
createProxy();

0 commit comments

Comments
 (0)