(baseUrl: string, defaultPort: number)
| 35 | // --------------------------------------------------------------------------- |
| 36 | |
| 37 | export const parseDaemonBaseUrl = (baseUrl: string, defaultPort: number): ParsedDaemonBaseUrl => { |
| 38 | const parsed = new URL(baseUrl); |
| 39 | |
| 40 | if (parsed.protocol !== "http:") { |
| 41 | throw new Error(`Only http:// base URLs are supported for daemon auto-start: ${baseUrl}`); |
| 42 | } |
| 43 | |
| 44 | const port = Number(parsed.port) || defaultPort; |
| 45 | if (!Number.isFinite(port) || port <= 0 || port > 65535) { |
| 46 | throw new Error(`Invalid daemon port in base URL: ${baseUrl}`); |
| 47 | } |
| 48 | |
| 49 | return { |
| 50 | hostname: parsed.hostname || "localhost", |
| 51 | port, |
| 52 | }; |
| 53 | }; |
| 54 | |
| 55 | // --------------------------------------------------------------------------- |
| 56 | // Local-host checks |
no outgoing calls
no test coverage detected