MCPcopy
hub / github.com/coder/mux / hostForRedirectUri

Function hostForRedirectUri

src/node/utils/oauthLoopbackServer.ts:95–104  ·  view source on GitHub ↗

* Format a `server.listen()` host value for use inside a URL. * * - IPv6 literals must be wrapped in brackets (e.g. "::1" -> "[::1]") * - Zone identifiers must be percent-encoded ("%" -> "%25")

(rawHost: string)

Source from the content-addressed store, hash-verified

93 * - Zone identifiers must be percent-encoded ("%" -> "%25")
94 */
95function hostForRedirectUri(rawHost: string): string {
96 const host = rawHost.startsWith("[") && rawHost.endsWith("]") ? rawHost.slice(1, -1) : rawHost;
97
98 if (host.includes(":")) {
99 // RFC 6874: zone identifiers use "%25" in URIs.
100 return `[${host.replaceAll("%", "%25")}]`;
101 }
102
103 return host;
104}
105
106// ---------------------------------------------------------------------------
107// Main

Callers 1

startLoopbackServerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected