Skip to content

escapeKeySegment

escapeKeySegment(value): string

Defined in: key-segment.ts:34

Escapes the structural characters of a :-joined composite key.

Joining raw values with : makes two different tuples collapse into one key whenever a value contains the separator:

['a:b', 'c'] → "a:b:c"
['a', 'b:c'] → "a:b:c" ← same key, different callers

Identifiers that reach a key are routinely email addresses, external subject claims and composite IDs. A collision means two callers share a rate-limit bucket or a cache entry.

The backslash is escaped first so that an input already containing one cannot be used to forge a separator.

string

string