Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 7 additions & 0 deletions bin/http-server
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ function listen(port) {
}
}

if (proxy) {
if (!proxy.startsWith('http://') && !proxy.startsWith('https://')) {
logger.info(colors.red('Error: Proxy must specify a protocol'));
process.exit(1);
}
}

if (ssl) {
options.https = {
cert: argv.C || argv.cert || 'cert.pem',
Expand Down
13 changes: 13 additions & 0 deletions test/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,16 @@ test('setting mimeTypes via cli - directly', (t) => {
});
});
});

test('--proxy requires you to specify a protocol', (t) => {
t.plan(1);

const options = ['.', '--proxy', 'google.com'];
const ecstatic = startEcstatic(options);

tearDown(ecstatic, t);

ecstatic.on('exit', (code) => {
t.equal(code, 1);
});
});