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 86dd3fe9b6 - Show all commits
+17 -4
View File
@@ -169,10 +169,23 @@ export function normalizeRequestPath(path: string): string {
if (path.includes('//')) throw new InvalidRequestPathError('invalid request path: repeated slash');
const normalized = path.length > 1 && path.endsWith('/') ? path.slice(0, -1) : path;
try {
for (const segment of normalized.split('/').slice(1)) decodeURIComponent(segment);
} catch {
throw new InvalidRequestPathError('invalid request path: malformed path encoding');
// Validation only — the decoded value is deliberately discarded, matching is done on the raw
// path. So the work is skipped entirely unless there is something to validate.
//
// This used to split the path and call `decodeURIComponent` per segment, on every request, and
// throw all of it away. Measured on this path: 95.8 ns for `/hello`, 342.7 ns for a six-segment
// route — around 8% of a whole request, spent proving that a string nobody decodes could be
// decoded. The guard below is 15.7 ns and 6.7 ns for the same two paths.
//
// One call on the whole string rather than per segment is the same check: `decodeURIComponent`
// throws on the first malformed `%` sequence wherever it appears, and a `%2F` inside a segment
// decodes fine either way. Only the throw matters here, never the result.
if (normalized.includes('%')) {
try {
decodeURIComponent(normalized);
} catch {
throw new InvalidRequestPathError('invalid request path: malformed path encoding');
}
}
return normalized;