diff --git a/src/node/app/proxy.ts b/src/node/app/proxy.ts index 19812cc10..354219139 100644 --- a/src/node/app/proxy.ts +++ b/src/node/app/proxy.ts @@ -17,7 +17,7 @@ export class ProxyHttpProvider extends HttpProvider implements HttpProxyProvider /** * Proxy domains are stored here without the leading `*.` */ - public readonly proxyDomains: string[] + public readonly proxyDomains: Set private readonly proxy = proxy.createProxyServer({}) /** @@ -26,7 +26,7 @@ export class ProxyHttpProvider extends HttpProvider implements HttpProxyProvider */ public constructor(options: HttpProviderOptions, proxyDomains: string[] = []) { super(options) - this.proxyDomains = proxyDomains.map((d) => d.replace(/^\*\./, "")).filter((d, i, arr) => arr.indexOf(d) === i) + this.proxyDomains = new Set(proxyDomains.map((d) => d.replace(/^\*\./, ""))) this.proxy.on("error", (error) => logger.warn(error.message)) // Intercept the response to rewrite absolute redirects against the base path. this.proxy.on("proxyRes", (response, request: Request) => { @@ -124,7 +124,7 @@ export class ProxyHttpProvider extends HttpProvider implements HttpProxyProvider // There must be an exact match. const port = parts.shift() const proxyDomain = parts.join(".") - if (!port || !this.proxyDomains.includes(proxyDomain)) { + if (!port || !this.proxyDomains.has(proxyDomain)) { return undefined } diff --git a/src/node/entry.ts b/src/node/entry.ts index e4f598349..6df34b7c2 100644 --- a/src/node/entry.ts +++ b/src/node/entry.ts @@ -94,10 +94,8 @@ const main = async (args: Args): Promise => { logger.info(" - Not serving HTTPS") } - if (proxy.proxyDomains.length === 1) { - logger.info(` - Proxying *.${proxy.proxyDomains[0]}`) - } else if (proxy.proxyDomains.length > 1) { - logger.info(" - Proxying the following domains:") + if (proxy.proxyDomains.size > 0) { + logger.info(` - Proxying the following domain${proxy.proxyDomains.size === 1 ? "" : "s"}:`) proxy.proxyDomains.forEach((domain) => logger.info(` - *.${domain}`)) }