Skip to content

Commit cb729b6

Browse files
authored
Merge pull request #5 from arihantjn53/ACE_1059_remove_any_protocol
Remove any protocol part from --proxy-host
2 parents 9666cee + f02fb06 commit cb729b6

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

config/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports.PORTS = {
1010
MAX: 65535,
1111
MIN: 1
1212
};
13+
module.exports.PROTOCOL_REGEX = /(^\w+:|^)\/\//;
1314

1415
module.exports.LOGS = Object.freeze({
1516
NETWORK: 'NetworkStats.log',

src/commandLine.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,10 @@ var CommandLineManager = {
119119
index = argv.indexOf('--proxy-host');
120120
if (index !== -1) {
121121
if (CommandLineManager.validArgValue(argv[index + 1])) {
122+
var host = argv[index + 1];
123+
host = host.replace(constants.PROTOCOL_REGEX, '');
122124
RdGlobalConfig.proxy = RdGlobalConfig.proxy || {};
123-
RdGlobalConfig.proxy.host = argv[index + 1];
125+
RdGlobalConfig.proxy.host = host;
124126
argv.splice(index, 2);
125127
} else {
126128
invalidArgs.add('--proxy-host');

test/commandLine.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@ describe('CommandLineManager', function () {
3838
expect(RdGlobalConfig.proxy.port).to.eql(9687);
3939
});
4040

41+
it('remove any protocol part from proxy-host', function () {
42+
sinon.stub(console, 'log');
43+
argv = argv.concat(['--proxy-host', 'http://host']);
44+
CommandLineManager.processArgs(argv);
45+
expect(RdGlobalConfig.proxy.host).to.eql('host');
46+
});
47+
48+
it('remove any prefix slashes from proxy-host', function () {
49+
argv = argv.concat(['--proxy-host', '//host']);
50+
CommandLineManager.processArgs(argv);
51+
console.log.restore();
52+
expect(RdGlobalConfig.proxy.host).to.eql('host');
53+
});
54+
4155
it('proxy-port is set to the default value when its not in the expected range', function () {
4256
sinon.stub(console, 'log');
4357
argv = argv.concat(['--proxy-host', 'host', '--proxy-port', '99999']);

0 commit comments

Comments
 (0)