(req: Request)
| 35 | * |
| 36 | */ |
| 37 | const maybeProxy = (req: Request): string | undefined => { |
| 38 | const reqDomain = getHost(req) |
| 39 | if (reqDomain === undefined) { |
| 40 | return undefined |
| 41 | } |
| 42 | |
| 43 | const regexs = proxyDomainsToRegex(req.args["proxy-domain"]) |
| 44 | |
| 45 | for (const regex of regexs) { |
| 46 | const match = reqDomain.match(regex) |
| 47 | |
| 48 | if (match) { |
| 49 | return match[1] // match[1] contains the port |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | return undefined |
| 54 | } |
| 55 | |
| 56 | router.all(/.*/, async (req, res, next) => { |
| 57 | const port = maybeProxy(req) |
no test coverage detected