From 830476db193c7b3b40ef6c9301d1db60de534556 Mon Sep 17 00:00:00 2001 From: whitecolor Date: Wed, 7 Jun 2017 17:02:51 +0500 Subject: [PATCH] fix sub-host cli handling --- bin/server | 3 +-- server.js | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/server b/bin/server index 70fb628..9e07f27 100755 --- a/bin/server +++ b/bin/server @@ -18,8 +18,7 @@ const argv = optimist describe: 'listen on this port for outside requests' }) .options('sub-host', { - describe: 'additionally listen on these sub hosts for outside requests', - type: 'array' + describe: 'additionally listen on this sub host for outside requests (can use this option multiple times)' }) .options('max-sockets', { default: 10, diff --git a/server.js b/server.js index c3be355..c046196 100644 --- a/server.js +++ b/server.js @@ -50,6 +50,8 @@ function maybe_bounce(req, res, sock, head, opt) { let subdomain = tldjs.getSubdomain(hostname); if (subdomain && opt.subHost) { + const subHosts = Array.isArray(opt.subHost) + ? opt.subHost : [opt.subHost] const subHost = opt.subHost.reduce((found, sub) => { return found || (subdomain.slice(-sub.length) == sub ? sub : '')