diff --git a/index.js b/index.js index 2dc4a07..44bb7b6 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,11 @@ +const tls = require('tls') + module.exports = (srv, hostname = 'localhost') => new Promise((resolve, reject) => { srv.on('error', reject) srv.listen(() => { const {port} = srv.address() - resolve(`http://${hostname}:${port}`) + const protocol = (srv instanceof tls.Server) ? 'https' : 'http' + resolve(`${protocol}://${hostname}:${port}`) }) })