@sveltejs/kit 1.0.0-next.473 → 1.0.0-next.474

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.0.0-next.473",
3
+ "version": "1.0.0-next.474",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -35,6 +35,8 @@ export async function handle_action_json_request(event, options, server) {
35
35
  });
36
36
  }
37
37
 
38
+ check_named_default_separate(actions);
39
+
38
40
  try {
39
41
  const data = await call_action(event, actions);
40
42
 
@@ -114,6 +116,8 @@ export async function handle_action_request(event, server) {
114
116
  };
115
117
  }
116
118
 
119
+ check_named_default_separate(actions);
120
+
117
121
  try {
118
122
  const data = await call_action(event, actions);
119
123
 
@@ -141,6 +145,17 @@ export async function handle_action_request(event, server) {
141
145
  }
142
146
  }
143
147
 
148
+ /**
149
+ * @param {import('types').Actions} actions
150
+ */
151
+ function check_named_default_separate(actions) {
152
+ if (actions.default && Object.keys(actions).length > 1) {
153
+ throw new Error(
154
+ `When using named actions, the default action cannot be used. See the docs for more info: https://kit.svelte.dev/docs/form-actions#named-actions`
155
+ );
156
+ }
157
+ }
158
+
144
159
  /**
145
160
  * @param {import('types').RequestEvent} event
146
161
  * @param {NonNullable<import('types').SSRNode['server']['actions']>} actions
@@ -153,6 +168,9 @@ export async function call_action(event, actions) {
153
168
  for (const param of url.searchParams) {
154
169
  if (param[0].startsWith('/')) {
155
170
  name = param[0].slice(1);
171
+ if (name === 'default') {
172
+ throw new Error('Cannot use reserved action name "default"');
173
+ }
156
174
  break;
157
175
  }
158
176
  }