(remoteMappings: RemoteMappingEntry[])
| 19 | }; |
| 20 | |
| 21 | export function mapDaemonAddress(remoteMappings: RemoteMappingEntry[]) { |
| 22 | const loc = window.location; |
| 23 | let addr = loc.host; |
| 24 | if (loc.port === "") { |
| 25 | if (loc.protocol === "http:") addr = `${addr}:80`; |
| 26 | if (loc.protocol === "https:") addr = `${addr}:443`; |
| 27 | } |
| 28 | const match = remoteMappings.find( |
| 29 | (entry) => |
| 30 | entry.from.addr === addr && |
| 31 | removeTrail(entry.from.prefix, "/") === removeTrail(loc.pathname, "/") |
| 32 | ); |
| 33 | if (!match) return undefined; |
| 34 | return match.to; |
| 35 | } |
| 36 | |
| 37 | export function parseForwardAddress(addr: string, require: "http" | "ws") { |
| 38 | // save its protocol header |
no test coverage detected