MCPcopy Create free account
hub / github.com/github/copilot-sdk / parseConnectTarget

Function parseConnectTarget

test/harness/connectProxy.ts:325–357  ·  view source on GitHub ↗
(authority: string)

Source from the content-addressed store, hash-verified

323}
324
325export function parseConnectTarget(authority: string): {
326 host: string;
327 port: string;
328} {
329 if (!authority) {
330 return { host: "", port: "" };
331 }
332
333 if (authority.startsWith("[")) {
334 const closeBracket = authority.indexOf("]");
335 if (closeBracket === -1) {
336 return { host: "", port: "" };
337 }
338 const host = authority.slice(1, closeBracket);
339 const afterBracket = authority.slice(closeBracket + 1);
340 if (afterBracket === "" || afterBracket === ":") {
341 return { host, port: "443" };
342 }
343 if (afterBracket[0] !== ":") {
344 return { host: "", port: "" };
345 }
346 return { host, port: afterBracket.slice(1) || "443" };
347 }
348
349 const lastColon = authority.lastIndexOf(":");
350 if (lastColon === -1) {
351 return { host: authority, port: "443" };
352 }
353
354 const host = authority.slice(0, lastColon);
355 const port = authority.slice(lastColon + 1) || "443";
356 return { host, port };
357}

Callers 2

handleConnectMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…