allowed for --sub-host to eqal 'sub.sub'

This commit is contained in:
mgudesblatart
2018-03-01 16:02:00 -05:00
parent dcddd2c0f7
commit 0eb59d42f9
4 changed files with 15 additions and 7 deletions
+4 -1
View File
@@ -12,17 +12,20 @@ const debug = Debug('localtunnel:server');
function GetClientIdFromHostname(hostname,opt) {
let subdomain = tldjs.getSubdomain(hostname);
if (subdomain && opt.subHost) {
const _subdomain = subdomain.replace(/\./g,'');
const subHosts = Array.isArray(opt.subHost)
? opt.subHost : [opt.subHost]
const subHost = subHosts.reduce((found, sub) => {
return found + (_subdomain.includes(sub) ? sub : '');
sub = sub.replace(/\./g,'');
return found + (_subdomain.includes(sub) ? sub : sub.includes(_subdomain) ? sub : '');
},'')
subdomain = subHost.length > 0
? _subdomain.slice(0, -(subHost.length))
: subdomain
}
return subdomain;
}