(backendUrl)
| 39 | } |
| 40 | |
| 41 | function parseBackendUrl(backendUrl) { |
| 42 | const url = new URL(backendUrl); |
| 43 | if (url.protocol !== "http:" && url.protocol !== "https:") { |
| 44 | throw new Error("Invalid backend URL"); |
| 45 | } |
| 46 | return { |
| 47 | hostname: url.hostname, |
| 48 | port: Number.parseInt(url.port, 10) || (url.protocol === "https:" ? 443 : 80), |
| 49 | protocol: url.protocol, |
| 50 | }; |
| 51 | } |
| 52 | |
| 53 | function writeInvalidBackendUrlResponse(req, res) { |
| 54 | const message = "Invalid backend URL"; |
no outgoing calls
no test coverage detected