(backendUrl)
| 71 | } |
| 72 | |
| 73 | function parseBackendUrl(backendUrl) { |
| 74 | const url = new URL(backendUrl); |
| 75 | if (url.protocol !== "http:" && url.protocol !== "https:") { |
| 76 | throw new Error("Invalid backend URL"); |
| 77 | } |
| 78 | return { |
| 79 | hostname: url.hostname, |
| 80 | port: |
| 81 | Number.parseInt(url.port, 10) || (url.protocol === "https:" ? 443 : 80), |
| 82 | protocol: url.protocol, |
| 83 | }; |
| 84 | } |
| 85 | |
| 86 | function writeInvalidBackendUrlResponse(req, res) { |
| 87 | const message = "Invalid backend URL"; |
no outgoing calls
no test coverage detected