@sveltejs/kit 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -8,6 +8,12 @@ import { normalize_path } from '../../utils/url.js';
8
8
  * @type {Record<string, Set<string>>} */
9
9
  const cookie_paths = {};
10
10
 
11
+ /**
12
+ * Cookies that are larger than this size (including the name and other
13
+ * attributes) are discarded by browsers
14
+ */
15
+ const MAX_COOKIE_SIZE = 4129;
16
+
11
17
  /**
12
18
  * @param {Request} request
13
19
  * @param {URL} url
@@ -111,6 +117,11 @@ export function get_cookies(request, url, trailing_slash) {
111
117
  };
112
118
 
113
119
  if (__SVELTEKIT_DEV__) {
120
+ const serialized = serialize(name, value, new_cookies[name].options);
121
+ if (new TextEncoder().encode(serialized).byteLength > MAX_COOKIE_SIZE) {
122
+ throw new Error(`Cookie "${name}" is too large, and will be discarded by the browser`);
123
+ }
124
+
114
125
  cookie_paths[name] = cookie_paths[name] ?? new Set();
115
126
  if (!value) {
116
127
  if (!cookie_paths[name].has(path) && cookie_paths[name].size > 0) {