function isValidHeaderName
isValidHeaderName(name: string): boolean

Whether a name is one HTTP will carry — the token characters RFC 9110 allows, and no others.

Checked here rather than left to fetch, which throws a TypeError naming neither the header nor what was wrong with it.

import { isValidHeaderName } from './http-service.ts';

isValidHeaderName('x-request-id'); // true
isValidHeaderName('x request id'); // false

Parameters

name: string

Return Type

boolean

Usage

import { isValidHeaderName } from "lib/repl/http-service.ts";