mirror of
https://github.com/withastro/astro.git
synced 2025-02-10 22:38:53 -05:00
* #9062: allow setting all cookie package serialize/parse options * 9062: fix scripts to original arrangement * feat: only add specific properties * Update tiny-days-dance.md * Add examples to the changeset * Update .changeset/tiny-days-dance.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Update .changeset/tiny-days-dance.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Update .changeset/tiny-days-dance.md Co-authored-by: Emanuele Stoppa <my.burning@gmail.com> * Update .changeset/tiny-days-dance.md Co-authored-by: Emanuele Stoppa <my.burning@gmail.com> --------- Co-authored-by: Arsh <69170106+lilnasy@users.noreply.github.com> Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev> Co-authored-by: Matthew Phillips <matthew@skypack.dev> Co-authored-by: Matthew Phillips <matthew@matthewphillips.info> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
28 lines
730 B
Markdown
28 lines
730 B
Markdown
---
|
|
'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)
|
|
});
|
|
---
|
|
```
|