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

Function getExpectedOrigins

src/node/orpc/server.ts:320–342  ·  view source on GitHub ↗
(req: OriginValidationRequest, allowHttpOrigin = false)

Source from the content-addressed store, hash-verified

318}
319
320function getExpectedOrigins(req: OriginValidationRequest, allowHttpOrigin = false): string[] {
321 const hosts = getExpectedHosts(req);
322
323 if (hosts.length === 0) {
324 return [];
325 }
326
327 const protocols = getExpectedProtocols(req, allowHttpOrigin);
328
329 const expectedOrigins: string[] = [];
330 for (const protocol of protocols) {
331 for (const host of hosts) {
332 const origin = buildOrigin(protocol, host);
333 if (!origin || expectedOrigins.includes(origin)) {
334 continue;
335 }
336
337 expectedOrigins.push(origin);
338 }
339 }
340
341 return expectedOrigins;
342}
343
344function normalizeOrigin(raw: string | null | undefined): string | null {
345 if (!raw) {

Callers 2

isOriginAllowedFunction · 0.85
createOrpcServerFunction · 0.85

Calls 4

getExpectedHostsFunction · 0.85
getExpectedProtocolsFunction · 0.85
buildOriginFunction · 0.85
pushMethod · 0.65

Tested by

no test coverage detected