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

Function normalizeOrigin

src/node/orpc/server.ts:344–361  ·  view source on GitHub ↗
(raw: string | null | undefined)

Source from the content-addressed store, hash-verified

342}
343
344function normalizeOrigin(raw: string | null | undefined): string | null {
345 if (!raw) {
346 return null;
347 }
348
349 try {
350 const parsed = new URL(raw);
351 const normalizedProtocol = normalizeProtocol(parsed.protocol);
352
353 if (!normalizedProtocol) {
354 return null;
355 }
356
357 return `${normalizedProtocol}://${parsed.host}`;
358 } catch {
359 return null;
360 }
361}
362
363interface OriginIdentity {
364 protocol: "http:" | "https:";

Callers 3

isOriginAllowedFunction · 0.70
createOrpcServerFunction · 0.70

Calls 1

normalizeProtocolFunction · 0.85

Tested by

no test coverage detected