(req: Request)
| 31 | middleware.find(({ handler }) => typeof handler === 'function' && handler.name === h.name) |
| 32 | |
| 33 | export const getProtocol = (req: Request): Protocol => { |
| 34 | const proto = req.connection.encrypted ? 'https' : 'http' |
| 35 | |
| 36 | if (!trustRemoteAddress(req)) return proto |
| 37 | |
| 38 | const header = (req.headers['X-Forwarded-Proto'] as string) || proto |
| 39 | |
| 40 | const index = header.indexOf(',') |
| 41 | |
| 42 | return index !== -1 ? header.substring(0, index).trim() : header.trim() |
| 43 | } |
| 44 | |
| 45 | export const getHostname = (req: Request): string | undefined => { |
| 46 | let host: string = req.get('X-Forwarded-Host') as string |
no test coverage detected