-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow setting all cookie package serialize/parse options (#9063)
* #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 <[email protected]> * Update .changeset/tiny-days-dance.md Co-authored-by: Sarah Rainsberger <[email protected]> * Update .changeset/tiny-days-dance.md Co-authored-by: Emanuele Stoppa <[email protected]> * Update .changeset/tiny-days-dance.md Co-authored-by: Emanuele Stoppa <[email protected]> --------- Co-authored-by: Arsh <[email protected]> Co-authored-by: Florian Lefebvre <[email protected]> Co-authored-by: Matthew Phillips <[email protected]> Co-authored-by: Matthew Phillips <[email protected]> Co-authored-by: Sarah Rainsberger <[email protected]> Co-authored-by: Emanuele Stoppa <[email protected]>
- Loading branch information
1 parent
08402ad
commit f33fe31
Showing
6 changed files
with
91 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
'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) | ||
}); | ||
--- | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters