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

Function getFirstHeaderValue

src/node/orpc/server.ts:180–193  ·  view source on GitHub ↗
(
  req: Pick<http.IncomingMessage, "headers">,
  headerName: string
)

Source from the content-addressed store, hash-verified

178};
179
180function getFirstHeaderValue(
181 req: Pick<http.IncomingMessage, "headers">,
182 headerName: string
183): string | null {
184 const rawValue = req.headers[headerName.toLowerCase()];
185 const value = Array.isArray(rawValue) ? rawValue[0] : rawValue;
186
187 if (typeof value !== "string") {
188 return null;
189 }
190
191 const firstValue = value.split(",")[0]?.trim();
192 return firstValue?.length ? firstValue : null;
193}
194
195function normalizeProtocol(rawProtocol: string): "http" | "https" | null {
196 const normalized = rawProtocol.trim().toLowerCase().replace(/:$/, "");

Callers 8

getExpectedHostsFunction · 0.70
isOriginAllowedFunction · 0.70
getRequestPublicBasePathFunction · 0.70
getValidatedPublicHostFunction · 0.70
createOrpcServerFunction · 0.70
getRequestIpAddressFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected