MCPcopy Index your code
hub / github.com/coder/mux / formatHostForUrl

Function formatHostForUrl

src/node/services/serverService.ts:70–83  ·  view source on GitHub ↗
(host: string)

Source from the content-addressed store, hash-verified

68}
69
70function formatHostForUrl(host: string): string {
71 const trimmed = host.trim();
72
73 // IPv6 URLs must be bracketed: http://[::1]:1234
74 if (trimmed.includes(":")) {
75 if (trimmed.startsWith("[") && trimmed.endsWith("]")) {
76 return trimmed;
77 }
78
79 return `[${trimmed}]`;
80 }
81
82 return trimmed;
83}
84
85function buildHttpBaseUrl(host: string, port: number): string {
86 return `http://${formatHostForUrl(host)}:${port}`;

Callers 1

buildHttpBaseUrlFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected