0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-20 22:12:38 -05:00
astro/.changeset/tiny-days-dance.md

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
730 B
Markdown
Raw Normal View History

---
'astro': minor
---
Cookie encoding / decoding can now be customized
Adds new `encode` and `decode` functions to allow customizing how cookies are encoded and decoded. For example, you can bypass the default encoding via `encodeURIComponent` when adding a URL as part of a cookie:
```astro
---
import { encodeCookieValue } from "./cookies";
Astro.cookies.set('url', Astro.url.toString(), {
// Override the default encoding so that URI components are not encoded
encode: value => encodeCookieValue(value)
});
---
```
Later, you can decode the URL in the same way:
```astro
---
import { decodeCookieValue } from "./cookies";
const url = Astro.cookies.get('url', {
decode: value => decodeCookieValue(value)
});
---
```