(full_spec: string)
| 31 | } |
| 32 | |
| 33 | export const parseSpec = (full_spec: string): RawSpecParts => { |
| 34 | let [head, listenAt] = rpartition(full_spec, "@"); |
| 35 | |
| 36 | if (!head) { |
| 37 | head = listenAt; |
| 38 | listenAt = ""; |
| 39 | } |
| 40 | |
| 41 | const [name, data] = partition(head, ":"); |
| 42 | let listen_host: string | undefined, listen_port: number | undefined; |
| 43 | |
| 44 | if (listenAt) { |
| 45 | let port: string; |
| 46 | if (listenAt.includes(":")) { |
| 47 | [listen_host, port] = rpartition(listenAt, ":"); |
| 48 | } else { |
| 49 | listen_host = ""; |
| 50 | port = listenAt; |
| 51 | } |
| 52 | if (port) { |
| 53 | listen_port = parseInt(port, 10); |
| 54 | if (isNaN(listen_port) || listen_port < 0 || listen_port > 65535) { |
| 55 | throw new Error(`invalid port: ${port}`); |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | return { |
| 60 | full_spec, |
| 61 | name, |
| 62 | data, |
| 63 | listen_host, |
| 64 | listen_port, |
| 65 | }; |
| 66 | }; |
no test coverage detected
searching dependent graphs…