Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

531 B
Raw Blame
export function sanitizeHttpHeaderName(name: string): string {
    const invalidHeaderNameChars = /[^!#$%&'*+\-.^_`|~0-9A-Za-z]/g
    return name.trim().replace(invalidHeaderNameChars, '')
}

export function sanitizeHttpHeaders(headers: Record<string, string> | undefined): Record<string, string> {
    if (!headers) {
        return {}
    }
    return Object.fromEntries(
        Object.entries(headers)
            .map(([key, value]) => [sanitizeHttpHeaderName(key), value])
            .filter(([key]) => key !== ''),
    )
}