@sveltejs/adapter-netlify 4.3.4 → 4.3.5

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/files/edge.js CHANGED
@@ -54,6 +54,8 @@ function is_static_file(request) {
54
54
  return (
55
55
  manifest.assets.has(file) ||
56
56
  manifest.assets.has(file + '/index.html') ||
57
+ file in manifest._.server_assets ||
58
+ file + '/index.html' in manifest._.server_assets ||
57
59
  prerendered.has(pathname || '/')
58
60
  );
59
61
  }
@@ -8,230 +8,240 @@ import 'node:crypto';
8
8
 
9
9
  var setCookie = {exports: {}};
10
10
 
11
- var defaultParseOptions = {
12
- decodeValues: true,
13
- map: false,
14
- silent: false,
15
- };
16
-
17
- function isNonEmptyString(str) {
18
- return typeof str === "string" && !!str.trim();
19
- }
11
+ var hasRequiredSetCookie;
20
12
 
21
- function parseString(setCookieValue, options) {
22
- var parts = setCookieValue.split(";").filter(isNonEmptyString);
23
-
24
- var nameValuePairStr = parts.shift();
25
- var parsed = parseNameValuePair(nameValuePairStr);
26
- var name = parsed.name;
27
- var value = parsed.value;
28
-
29
- options = options
30
- ? Object.assign({}, defaultParseOptions, options)
31
- : defaultParseOptions;
32
-
33
- try {
34
- value = options.decodeValues ? decodeURIComponent(value) : value; // decode cookie value
35
- } catch (e) {
36
- console.error(
37
- "set-cookie-parser encountered an error while decoding a cookie with value '" +
38
- value +
39
- "'. Set options.decodeValues to false to disable this feature.",
40
- e
41
- );
42
- }
43
-
44
- var cookie = {
45
- name: name,
46
- value: value,
47
- };
48
-
49
- parts.forEach(function (part) {
50
- var sides = part.split("=");
51
- var key = sides.shift().trimLeft().toLowerCase();
52
- var value = sides.join("=");
53
- if (key === "expires") {
54
- cookie.expires = new Date(value);
55
- } else if (key === "max-age") {
56
- cookie.maxAge = parseInt(value, 10);
57
- } else if (key === "secure") {
58
- cookie.secure = true;
59
- } else if (key === "httponly") {
60
- cookie.httpOnly = true;
61
- } else if (key === "samesite") {
62
- cookie.sameSite = value;
63
- } else {
64
- cookie[key] = value;
65
- }
66
- });
67
-
68
- return cookie;
69
- }
13
+ function requireSetCookie () {
14
+ if (hasRequiredSetCookie) return setCookie.exports;
15
+ hasRequiredSetCookie = 1;
70
16
 
71
- function parseNameValuePair(nameValuePairStr) {
72
- // Parses name-value-pair according to rfc6265bis draft
17
+ var defaultParseOptions = {
18
+ decodeValues: true,
19
+ map: false,
20
+ silent: false,
21
+ };
73
22
 
74
- var name = "";
75
- var value = "";
76
- var nameValueArr = nameValuePairStr.split("=");
77
- if (nameValueArr.length > 1) {
78
- name = nameValueArr.shift();
79
- value = nameValueArr.join("="); // everything after the first =, joined by a "=" if there was more than one part
80
- } else {
81
- value = nameValuePairStr;
82
- }
23
+ function isNonEmptyString(str) {
24
+ return typeof str === "string" && !!str.trim();
25
+ }
83
26
 
84
- return { name: name, value: value };
85
- }
27
+ function parseString(setCookieValue, options) {
28
+ var parts = setCookieValue.split(";").filter(isNonEmptyString);
29
+
30
+ var nameValuePairStr = parts.shift();
31
+ var parsed = parseNameValuePair(nameValuePairStr);
32
+ var name = parsed.name;
33
+ var value = parsed.value;
34
+
35
+ options = options
36
+ ? Object.assign({}, defaultParseOptions, options)
37
+ : defaultParseOptions;
38
+
39
+ try {
40
+ value = options.decodeValues ? decodeURIComponent(value) : value; // decode cookie value
41
+ } catch (e) {
42
+ console.error(
43
+ "set-cookie-parser encountered an error while decoding a cookie with value '" +
44
+ value +
45
+ "'. Set options.decodeValues to false to disable this feature.",
46
+ e
47
+ );
48
+ }
49
+
50
+ var cookie = {
51
+ name: name,
52
+ value: value,
53
+ };
54
+
55
+ parts.forEach(function (part) {
56
+ var sides = part.split("=");
57
+ var key = sides.shift().trimLeft().toLowerCase();
58
+ var value = sides.join("=");
59
+ if (key === "expires") {
60
+ cookie.expires = new Date(value);
61
+ } else if (key === "max-age") {
62
+ cookie.maxAge = parseInt(value, 10);
63
+ } else if (key === "secure") {
64
+ cookie.secure = true;
65
+ } else if (key === "httponly") {
66
+ cookie.httpOnly = true;
67
+ } else if (key === "samesite") {
68
+ cookie.sameSite = value;
69
+ } else {
70
+ cookie[key] = value;
71
+ }
72
+ });
73
+
74
+ return cookie;
75
+ }
86
76
 
87
- function parse(input, options) {
88
- options = options
89
- ? Object.assign({}, defaultParseOptions, options)
90
- : defaultParseOptions;
91
-
92
- if (!input) {
93
- if (!options.map) {
94
- return [];
95
- } else {
96
- return {};
97
- }
98
- }
99
-
100
- if (input.headers) {
101
- if (typeof input.headers.getSetCookie === "function") {
102
- // for fetch responses - they combine headers of the same type in the headers array,
103
- // but getSetCookie returns an uncombined array
104
- input = input.headers.getSetCookie();
105
- } else if (input.headers["set-cookie"]) {
106
- // fast-path for node.js (which automatically normalizes header names to lower-case
107
- input = input.headers["set-cookie"];
108
- } else {
109
- // slow-path for other environments - see #25
110
- var sch =
111
- input.headers[
112
- Object.keys(input.headers).find(function (key) {
113
- return key.toLowerCase() === "set-cookie";
114
- })
115
- ];
116
- // warn if called on a request-like object with a cookie header rather than a set-cookie header - see #34, 36
117
- if (!sch && input.headers.cookie && !options.silent) {
118
- console.warn(
119
- "Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."
120
- );
121
- }
122
- input = sch;
123
- }
124
- }
125
- if (!Array.isArray(input)) {
126
- input = [input];
127
- }
128
-
129
- options = options
130
- ? Object.assign({}, defaultParseOptions, options)
131
- : defaultParseOptions;
132
-
133
- if (!options.map) {
134
- return input.filter(isNonEmptyString).map(function (str) {
135
- return parseString(str, options);
136
- });
137
- } else {
138
- var cookies = {};
139
- return input.filter(isNonEmptyString).reduce(function (cookies, str) {
140
- var cookie = parseString(str, options);
141
- cookies[cookie.name] = cookie;
142
- return cookies;
143
- }, cookies);
144
- }
145
- }
77
+ function parseNameValuePair(nameValuePairStr) {
78
+ // Parses name-value-pair according to rfc6265bis draft
79
+
80
+ var name = "";
81
+ var value = "";
82
+ var nameValueArr = nameValuePairStr.split("=");
83
+ if (nameValueArr.length > 1) {
84
+ name = nameValueArr.shift();
85
+ value = nameValueArr.join("="); // everything after the first =, joined by a "=" if there was more than one part
86
+ } else {
87
+ value = nameValuePairStr;
88
+ }
89
+
90
+ return { name: name, value: value };
91
+ }
92
+
93
+ function parse(input, options) {
94
+ options = options
95
+ ? Object.assign({}, defaultParseOptions, options)
96
+ : defaultParseOptions;
97
+
98
+ if (!input) {
99
+ if (!options.map) {
100
+ return [];
101
+ } else {
102
+ return {};
103
+ }
104
+ }
105
+
106
+ if (input.headers) {
107
+ if (typeof input.headers.getSetCookie === "function") {
108
+ // for fetch responses - they combine headers of the same type in the headers array,
109
+ // but getSetCookie returns an uncombined array
110
+ input = input.headers.getSetCookie();
111
+ } else if (input.headers["set-cookie"]) {
112
+ // fast-path for node.js (which automatically normalizes header names to lower-case
113
+ input = input.headers["set-cookie"];
114
+ } else {
115
+ // slow-path for other environments - see #25
116
+ var sch =
117
+ input.headers[
118
+ Object.keys(input.headers).find(function (key) {
119
+ return key.toLowerCase() === "set-cookie";
120
+ })
121
+ ];
122
+ // warn if called on a request-like object with a cookie header rather than a set-cookie header - see #34, 36
123
+ if (!sch && input.headers.cookie && !options.silent) {
124
+ console.warn(
125
+ "Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."
126
+ );
127
+ }
128
+ input = sch;
129
+ }
130
+ }
131
+ if (!Array.isArray(input)) {
132
+ input = [input];
133
+ }
134
+
135
+ options = options
136
+ ? Object.assign({}, defaultParseOptions, options)
137
+ : defaultParseOptions;
138
+
139
+ if (!options.map) {
140
+ return input.filter(isNonEmptyString).map(function (str) {
141
+ return parseString(str, options);
142
+ });
143
+ } else {
144
+ var cookies = {};
145
+ return input.filter(isNonEmptyString).reduce(function (cookies, str) {
146
+ var cookie = parseString(str, options);
147
+ cookies[cookie.name] = cookie;
148
+ return cookies;
149
+ }, cookies);
150
+ }
151
+ }
152
+
153
+ /*
154
+ Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
155
+ that are within a single set-cookie field-value, such as in the Expires portion.
156
+
157
+ This is uncommon, but explicitly allowed - see https://tools.ietf.org/html/rfc2616#section-4.2
158
+ Node.js does this for every header *except* set-cookie - see https://github.com/nodejs/node/blob/d5e363b77ebaf1caf67cd7528224b651c86815c1/lib/_http_incoming.js#L128
159
+ React Native's fetch does this for *every* header, including set-cookie.
160
+
161
+ Based on: https://github.com/google/j2objc/commit/16820fdbc8f76ca0c33472810ce0cb03d20efe25
162
+ Credits to: https://github.com/tomball for original and https://github.com/chrusart for JavaScript implementation
163
+ */
164
+ function splitCookiesString(cookiesString) {
165
+ if (Array.isArray(cookiesString)) {
166
+ return cookiesString;
167
+ }
168
+ if (typeof cookiesString !== "string") {
169
+ return [];
170
+ }
171
+
172
+ var cookiesStrings = [];
173
+ var pos = 0;
174
+ var start;
175
+ var ch;
176
+ var lastComma;
177
+ var nextStart;
178
+ var cookiesSeparatorFound;
179
+
180
+ function skipWhitespace() {
181
+ while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
182
+ pos += 1;
183
+ }
184
+ return pos < cookiesString.length;
185
+ }
186
+
187
+ function notSpecialChar() {
188
+ ch = cookiesString.charAt(pos);
189
+
190
+ return ch !== "=" && ch !== ";" && ch !== ",";
191
+ }
192
+
193
+ while (pos < cookiesString.length) {
194
+ start = pos;
195
+ cookiesSeparatorFound = false;
196
+
197
+ while (skipWhitespace()) {
198
+ ch = cookiesString.charAt(pos);
199
+ if (ch === ",") {
200
+ // ',' is a cookie separator if we have later first '=', not ';' or ','
201
+ lastComma = pos;
202
+ pos += 1;
203
+
204
+ skipWhitespace();
205
+ nextStart = pos;
206
+
207
+ while (pos < cookiesString.length && notSpecialChar()) {
208
+ pos += 1;
209
+ }
210
+
211
+ // currently special character
212
+ if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
213
+ // we found cookies separator
214
+ cookiesSeparatorFound = true;
215
+ // pos is inside the next cookie, so back up and return it.
216
+ pos = nextStart;
217
+ cookiesStrings.push(cookiesString.substring(start, lastComma));
218
+ start = pos;
219
+ } else {
220
+ // in param ',' or param separator ';',
221
+ // we continue from that comma
222
+ pos = lastComma + 1;
223
+ }
224
+ } else {
225
+ pos += 1;
226
+ }
227
+ }
228
+
229
+ if (!cookiesSeparatorFound || pos >= cookiesString.length) {
230
+ cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
231
+ }
232
+ }
233
+
234
+ return cookiesStrings;
235
+ }
146
236
 
147
- /*
148
- Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
149
- that are within a single set-cookie field-value, such as in the Expires portion.
150
-
151
- This is uncommon, but explicitly allowed - see https://tools.ietf.org/html/rfc2616#section-4.2
152
- Node.js does this for every header *except* set-cookie - see https://github.com/nodejs/node/blob/d5e363b77ebaf1caf67cd7528224b651c86815c1/lib/_http_incoming.js#L128
153
- React Native's fetch does this for *every* header, including set-cookie.
154
-
155
- Based on: https://github.com/google/j2objc/commit/16820fdbc8f76ca0c33472810ce0cb03d20efe25
156
- Credits to: https://github.com/tomball for original and https://github.com/chrusart for JavaScript implementation
157
- */
158
- function splitCookiesString(cookiesString) {
159
- if (Array.isArray(cookiesString)) {
160
- return cookiesString;
161
- }
162
- if (typeof cookiesString !== "string") {
163
- return [];
164
- }
165
-
166
- var cookiesStrings = [];
167
- var pos = 0;
168
- var start;
169
- var ch;
170
- var lastComma;
171
- var nextStart;
172
- var cookiesSeparatorFound;
173
-
174
- function skipWhitespace() {
175
- while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
176
- pos += 1;
177
- }
178
- return pos < cookiesString.length;
179
- }
180
-
181
- function notSpecialChar() {
182
- ch = cookiesString.charAt(pos);
183
-
184
- return ch !== "=" && ch !== ";" && ch !== ",";
185
- }
186
-
187
- while (pos < cookiesString.length) {
188
- start = pos;
189
- cookiesSeparatorFound = false;
190
-
191
- while (skipWhitespace()) {
192
- ch = cookiesString.charAt(pos);
193
- if (ch === ",") {
194
- // ',' is a cookie separator if we have later first '=', not ';' or ','
195
- lastComma = pos;
196
- pos += 1;
197
-
198
- skipWhitespace();
199
- nextStart = pos;
200
-
201
- while (pos < cookiesString.length && notSpecialChar()) {
202
- pos += 1;
203
- }
204
-
205
- // currently special character
206
- if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
207
- // we found cookies separator
208
- cookiesSeparatorFound = true;
209
- // pos is inside the next cookie, so back up and return it.
210
- pos = nextStart;
211
- cookiesStrings.push(cookiesString.substring(start, lastComma));
212
- start = pos;
213
- } else {
214
- // in param ',' or param separator ';',
215
- // we continue from that comma
216
- pos = lastComma + 1;
217
- }
218
- } else {
219
- pos += 1;
220
- }
221
- }
222
-
223
- if (!cookiesSeparatorFound || pos >= cookiesString.length) {
224
- cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
225
- }
226
- }
227
-
228
- return cookiesStrings;
237
+ setCookie.exports = parse;
238
+ setCookie.exports.parse = parse;
239
+ setCookie.exports.parseString = parseString;
240
+ setCookie.exports.splitCookiesString = splitCookiesString;
241
+ return setCookie.exports;
229
242
  }
230
243
 
231
- setCookie.exports = parse;
232
- setCookie.exports.parse = parse;
233
- setCookie.exports.parseString = parseString;
234
- var splitCookiesString_1 = setCookie.exports.splitCookiesString = splitCookiesString;
244
+ var setCookieExports = /*@__PURE__*/ requireSetCookie();
235
245
 
236
246
  /**
237
247
  * Splits headers into two categories: single value and multi value
@@ -251,7 +261,7 @@ function split_headers(headers) {
251
261
  headers.forEach((value, key) => {
252
262
  if (key === 'set-cookie') {
253
263
  if (!m[key]) m[key] = [];
254
- m[key].push(...splitCookiesString_1(value));
264
+ m[key].push(...setCookieExports.splitCookiesString(value));
255
265
  } else {
256
266
  h[key] = value;
257
267
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/adapter-netlify",
3
- "version": "4.3.4",
3
+ "version": "4.3.5",
4
4
  "description": "A SvelteKit adapter that creates a Netlify app",
5
5
  "keywords": [
6
6
  "adapter",
@@ -38,16 +38,16 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "@netlify/functions": "^2.4.1",
41
- "@rollup/plugin-commonjs": "^26.0.1",
41
+ "@rollup/plugin-commonjs": "^28.0.0",
42
42
  "@rollup/plugin-json": "^6.1.0",
43
- "@rollup/plugin-node-resolve": "^15.2.3",
43
+ "@rollup/plugin-node-resolve": "^15.3.0",
44
44
  "@sveltejs/vite-plugin-svelte": "^3.0.1",
45
45
  "@types/node": "^18.19.48",
46
46
  "@types/set-cookie-parser": "^2.4.7",
47
47
  "rollup": "^4.14.2",
48
48
  "typescript": "^5.3.3",
49
49
  "vitest": "^2.0.1",
50
- "@sveltejs/kit": "^2.5.28"
50
+ "@sveltejs/kit": "^2.7.0"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "@sveltejs/kit": "^2.4.0"