Skip to content

[Housekeeping] canonicalPathname double-slash 308 redirect; deferred notFound() keeps HTTP 200 #58

Description

@thinkter

Security-audit housekeeping notes, commit abf4e87. Two low-impact correctness items.

(a) canonicalPathname does not collapse internal //, so the 308 redirect emits a double-slash Location

File: src/server.ts:56-58 (canonicalPathname) vs src/core/path.ts:8 (normalizePathname)

normalizePathname collapses internal //, but canonicalPathname does not. As a result the trailing-slash 308 redirect can emit a Location header that still contains double slashes, which then normalizes on the follow-up request → a redundant extra round-trip.

Suggested fix: collapse internal // in canonicalPathname (reuse normalizePathname's logic) so the 308 target is already fully canonical.

(b) Deferred-phase notFound() keeps HTTP 200

File: src/core/render.ts:231-233

The deferred phase ignores deeper.status, so a notFound() raised during the deferred phase still returns HTTP 200 with not-found content. This is acceptable (headers are already committed once the stream has flushed), but is a surprising behavior.

Suggested fix: add a code comment documenting that the deferred-phase status is intentionally left at 200 because headers are already committed, so future readers don't treat it as a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: routingPath normalization, route precedence, intercept markersbugSomething isn't workingseverity: low-hangingPolish, tech debt, missing docs

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions