MCPcopy Create free account
hub / github.com/coder/mux / buildOrigin

Function buildOrigin

src/node/orpc/server.ts:204–217  ·  view source on GitHub ↗
(protocol: string, host: string)

Source from the content-addressed store, hash-verified

202}
203
204function buildOrigin(protocol: string, host: string): string | null {
205 const normalizedProtocol = normalizeProtocol(protocol);
206 const normalizedHost = host.trim();
207
208 if (!normalizedProtocol || normalizedHost.length === 0) {
209 return null;
210 }
211
212 try {
213 return new URL(`${normalizedProtocol}://${normalizedHost}`).origin;
214 } catch {
215 return null;
216 }
217}
218
219function normalizeHostForProtocol(host: string, protocol: "http" | "https"): string | null {
220 const trimmedHost = host.trim();

Callers 1

getExpectedOriginsFunction · 0.85

Calls 1

normalizeProtocolFunction · 0.85

Tested by

no test coverage detected