next.js
1f0cd93b - [refactor] Rename `encodeCacheTag` to `encodeHeaderSafe` (#96936)

Commit
72 days ago
[refactor] Rename `encodeCacheTag` to `encodeHeaderSafe` (#96936) The helper percent-encodes anything outside Node's valid header-value class so a string can be serialized into an HTTP header. That is a property of the transport, not of cache tags, and the next caller is `unstable_cache`'s synthetic `fetchUrl`, which is a cache item name rather than a tag. Naming the function after one of its callers would make that call site read as though it were tagging something. This change renames the module to `encode-header-safe.ts` and the function to `encodeHeaderSafe`, and generalizes the leading paragraph of the doc comment accordingly. The rationale specific to cache tags stays, since tag construction and invalidation remain the callers today. The doc now also names the `ByteString` conversion that `fetch` performs on header values, alongside `validateHeaderValue`; both already applied to tags, because the Vercel bridge sends them through `fetch`. There is no behavior change. The function body is identical apart from the parameter name.
Author
Parents
Loading