diff --git a/index.js b/index.js index 833d01d..e7b50e7 100644 --- a/index.js +++ b/index.js @@ -8,7 +8,7 @@ var utils = function() { * * @returns IPv4 address. */ - var currentAddress = function() { + var currentAddress = function(port) { var networkInterfaces = os.networkInterfaces( ); for (var networkInterface in networkInterfaces) { var iface = networkInterfaces[networkInterface]; @@ -16,7 +16,7 @@ var utils = function() { for (var i = 0; i < iface.length; i++) { var name = iface[i]; if (name.address !== "127.0.0.1" && name.family === "IPv4" && !name.internal) { - return "http://" + name.address; + return "http://" + name.address + ":" + port; } } } diff --git a/test/index.js b/test/index.js index 04c3d21..563d919 100644 --- a/test/index.js +++ b/test/index.js @@ -26,7 +26,7 @@ describe("utils", function(){ ]} ); - assert.equal(utils.currentAddress(), "http://192.168.0.7"); + assert.equal(utils.currentAddress(9), "http://192.168.0.7:9"); }); it("shouldn't return network address if no external IPv4 is available", function(){ @@ -40,7 +40,7 @@ describe("utils", function(){ ]} ); - assert.equal(utils.currentAddress(), undefined); + assert.equal(utils.currentAddress(9), undefined); }); }); });