release: promote 26.8.0-beta.1 — the trust release #43

Merged
chrnx merged 49 commits from develop into main 2026-08-17 23:28:33 +00:00
Showing only changes of commit 8d8ef7ed09 - Show all commits
+12 -2
View File
@@ -1,5 +1,7 @@
import { mergeVary } from '../security';
const hasOwn = Object.prototype.hasOwnProperty;
/**
* Merges a handler's response headers with authoritative `injected` headers
* (security + CORS). Injected keys win case-insensitively; `vary` is merged.
@@ -10,7 +12,6 @@ export function mergeInjectedHeaders(
injected: Record<string, string>,
): Record<string, any> {
const merged: Record<string, any> = {};
const injectedLower = new Set(Object.keys(injected).map((key) => key.toLowerCase()));
let handlerVary: string | undefined;
if (handlerHeaders)
@@ -22,7 +23,16 @@ export function mergeInjectedHeaders(
continue;
}
if (!injectedLower.has(lowerKey)) merged[key] = handlerHeaders[key];
// `injected` is looked up directly instead of through a lowercased Set rebuilt per response.
// Every key it can hold is written as a lowercase literal in `src/security.ts` — both
// `buildSecurityHeaders` and `resolveCors`, which are its only sources — so lowercasing them
// again produced a copy of the keys it already had. Three allocations per response (an array,
// a mapped array, a Set) to answer a question the object answers itself: 146.4 ns against
// 55.9 ns.
//
// `hasOwnProperty` rather than `in`: a handler is free to send a header called `constructor`
// or `toString`, and `in` would find those on Object.prototype and silently drop them.
if (!hasOwn.call(injected, lowerKey)) merged[key] = handlerHeaders[key];
}
Object.assign(merged, injected);