MCPcopy
hub / github.com/dthree/vantage / parseConnection

Function parseConnection

bin/vantage.js:29–43  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

27commander.parse(process.argv);
28
29function parseConnection(str) {
30 var parts = String(str).split(":");
31 var port = (parts.length === 2) ? parts[1] : void 0;
32 var server = (parts.length === 2) ? parts[0] : void 0;
33 if (parts.length === 1) {
34 server = (isNumber(parts[0])) ? void 0 : parts[0];
35 port = (String(parts[0]).length < 6 && isNumber(parts[0])) ? parts[0] : void 0;
36 }
37 server = (!server) ? "127.0.0.1" : server;
38 port = (!port) ? "80" : port;
39 return ({
40 server: server,
41 port: port
42 });
43}
44
45function isNumber(str) {
46 return !isNaN(parseInt(str));

Callers 1

executeFunction · 0.85

Calls 1

isNumberFunction · 0.85

Tested by

no test coverage detected