vike
Version:
The Framework *You* Control - Next.js & Nuxt alternative for unprecedented flexibility and dependability.
18 lines (17 loc) • 955 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizeHeaders = normalizeHeaders;
const isObject_js_1 = require("./isObject.js");
function normalizeHeaders(
/* This type is too strict which is annoying: cannot pass `string[][]` because it doesn't match the more precise type `[string,string][]`.
headersOriginal ConstructorParameters<typeof Headers>[0]
*/
headersOriginal) {
let headersCleaned = headersOriginal;
// Copied from https://github.com/hattipjs/hattip/blob/69237d181300b200a14114df2c3c115c44e0f3eb/packages/adapter/adapter-node/src/request.ts#L78-L83
if ((0, isObject_js_1.isObject)(headersCleaned) && headersCleaned[':method'])
headersCleaned = Object.fromEntries(Object.entries(headersCleaned).filter(([key]) => !key.startsWith(':')));
const headersStandard = new Headers(headersCleaned);
const headers = Object.fromEntries(headersStandard.entries());
return headers;
}