fn

decodeCookieValue

v0.0.5

Decodes a cookie value: unwraps an RFC 6265 DQUOTE-wrapped value (the quotes are transport dressing, not payload), then decodes percent-escapes. Malformed escapes (e.g. third-party cookies that never used percent-encoding) are returned as-is instead of throwing.

Examples

ts
decodeCookieValue('a%3Bb'); // 'a;b'
ts
decodeCookieValue('"dark"'); // 'dark'

Signature

ts
declare function decodeCookieValue(value: string): string;

Parameters

ParameterTypeDescription
valuestringThe encoded cookie value

Returns

stringThe decoded cookie value