mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-16 03:31:10 +00:00
16 lines
539 B
TypeScript
16 lines
539 B
TypeScript
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
|
|
|
|
export type HttpHeaderMap = Record<string, string | string[] | undefined>;
|
|
|
|
export function getHeader(headers: HttpHeaderMap, name: string): string | undefined {
|
|
const target = normalizeLowercaseStringOrEmpty(name);
|
|
const direct = headers[target];
|
|
const value =
|
|
direct ??
|
|
Object.entries(headers).find(([key]) => normalizeLowercaseStringOrEmpty(key) === target)?.[1];
|
|
if (Array.isArray(value)) {
|
|
return value[0];
|
|
}
|
|
return value;
|
|
}
|