Documentation
    Preparing search index...
    • The parameter's value as one URL path segment: its text URI-encoded, or "null" when the value is nullish.

      . and .. are refused. encodeURIComponent leaves them as they are, and the URL parser that fetch and new URL() share resolves them as dot segments, so the request would reach the parent path instead of the route, with the value gone. Their percent-encoded form is a dot segment by the same standard, so no spelling carries them.

      Parameters

      • name: string

        Name of the parameter, for the error

      • value: unknown

        Value of the parameter

      Returns string

      The URI-encoded segment

      Error when the value is . or ..

      contracts/common.md#principled-implementation encodeURIComponent produces a single segment for well-formed Unicode text and throws URIError for unpaired surrogates; nullish input becomes the text null. The encoded text . or .. is refused because the WHATWG URL parser treats it and its percent-encoded spelling as a dot segment.

      contracts/common.md#clear-and-simple-design One conversion and one guard, with the reason for the guard stated in the comment.

      contracts/common.md#prohibited-implementation-shortcuts The guard prevents a request from silently reaching a different route, so it is a correctness check rather than a workaround for a test.

      contracts/common.md#meaningful-documentation The comment states the encoding, the nullish rule, the refused segments, their reason, and the thrown error.