From 445387df1c63790ab1d71cb15baae871023c8531 Mon Sep 17 00:00:00 2001 From: cel Date: Sun, 2 Sep 2018 12:46:05 -0700 Subject: Fix listening on localhost and printing address --- lib/app.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/app.js b/lib/app.js index 5b3035a..8b6d897 100644 --- a/lib/app.js +++ b/lib/app.js @@ -76,11 +76,11 @@ App.prototype.go = function () { var server = http.createServer(function (req, res) { new Serve(self, req, res).go() }) - if (self.host === 'localhost') server.listen(self.port, onListening) - else server.listen(self.port, self.host, onListening) + server.listen(self.port, self.host, onListening) function onListening() { - var host = /:/.test(self.host) ? '[' + self.host + ']' : self.host - self.log('Listening on http://' + host + ':' + self.port) + var addr = server.address() + var host = addr.family === 'IPv6' ? '[' + addr.address + ']' : addr.address + self.log('Listening on http://' + host + ':' + addr.port) } // invalidate cached About info when new About messages come in -- cgit v1.2.3