Skip to content

Commit 34cba38

Browse files
committed
[fix] Fixed cli parsing issue when --argument=value is not used
1 parent 8ef2e1f commit 34cba38

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

bin/node-http-proxy

+7-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ var help = [
1717
" --config OUTFILE Location of the configuration file for the proxy server",
1818
" --silent Silence the log output from the proxy server",
1919
" -h, --help You're staring at it"
20-
];
20+
].join('\n');
2121

2222
if (argv.h || argv.help || Object.keys(argv).length === 2) {
23-
util.puts(help.join('\n'));
23+
util.puts(help);
2424
process.exit(0);
2525
}
2626

@@ -49,7 +49,7 @@ config.silent = typeof argv.silent !== 'undefined' ? argv.silent : config.silent
4949
//
5050
// If we were passed a target, parse the url string
5151
//
52-
if (target) location = target.split(':');
52+
if (typeof target === 'string') location = target.split(':');
5353

5454
//
5555
// Create the server with the specified options
@@ -59,9 +59,12 @@ if (location) {
5959
var targetPort = location.length === 1 ? 80 : location[1];
6060
server = httpProxy.createServer(targetPort, location[0], config);
6161
}
62-
else {
62+
else if (config.router) {
6363
server = httpProxy.createServer(config);
6464
}
65+
else {
66+
return util.puts(help);
67+
}
6568

6669
//
6770
// Start the server

0 commit comments

Comments
 (0)