MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / mapDaemonAddress

Function mapDaemonAddress

frontend/src/tools/protocol.ts:21–35  ·  view source on GitHub ↗
(remoteMappings: RemoteMappingEntry[])

Source from the content-addressed store, hash-verified

19};
20
21export 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
37export function parseForwardAddress(addr: string, require: "http" | "ws") {
38 // save its protocol header

Callers 3

getFileConfigAddrFunction · 0.90
executeFunction · 0.90
testFrontendSocketFunction · 0.90

Calls 1

removeTrailFunction · 0.90

Tested by

no test coverage detected