Skip to content

Commit

Permalink
Merge branch 'master' into version-2
Browse files Browse the repository at this point in the history
  • Loading branch information
dummdidumm committed Dec 12, 2023
2 parents bc88038 + 5faf68e commit 63ad25a
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/honest-terms-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: correctly return 415 when unexpected content types are submitted to actions
5 changes: 0 additions & 5 deletions .changeset/nervous-mails-tickle.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/warm-impalas-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

chore: deprecate `preloadCode` calls with multiple arguments
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ The `fallback` page is an HTML page created by SvelteKit from your page template

On some hosts it may be `index.html` or something else entirely — consult your platform's documentation.

> Note that the fallback page will always contain absolute asset paths (i.e. beginning with `/` rather than `.`) regardless of the value of [`paths.relative`](/docs/configuration#paths), since it is used to respond to requests for arbitrary paths.
## Apache

To run an SPA on [Apache](https://httpd.apache.org/), you should add a `static/.htaccess` file to route requests to the fallback page:
Expand All @@ -58,4 +60,4 @@ If you want certain pages to be prerendered, you can re-enable `ssr` alongside `
/// file: src/routes/my-prerendered-page/+page.js
export const prerender = true;
export const ssr = true;
```
```
6 changes: 6 additions & 0 deletions packages/kit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @sveltejs/kit

## 1.29.0

### Minor Changes

- feat: add `resolveRoute` to `$app/paths`, deprecate `resolvePath` ([#11261](https://github.com/sveltejs/kit/pull/11261))

## 1.28.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sveltejs/kit",
"version": "1.28.0",
"version": "1.29.0",
"description": "The fastest way to build Svelte apps",
"repository": {
"type": "git",
Expand Down
2 changes: 2 additions & 0 deletions packages/kit/src/exports/public.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ export interface KitConfig {
* If `true`, `base` and `assets` imported from `$app/paths` will be replaced with relative asset paths during server-side rendering, resulting in more portable HTML.
* If `false`, `%sveltekit.assets%` and references to build artifacts will always be root-relative paths, unless `paths.assets` is an external URL
*
* [Single-page app](https://kit.svelte.dev/docs/single-page-apps) fallback pages will always use absolute paths, regardless of this setting.
*
* If your app uses a `<base>` element, you should set this to `false`, otherwise asset URLs will incorrectly be resolved against the `<base>` URL rather than the current page.
*
* In 1.0, `undefined` was a valid value, which was set by default. In that case, if `paths.assets` was not external, SvelteKit would replace `%sveltekit.assets%` with a relative path and use relative paths to reference build artifacts, but `base` and `assets` imported from `$app/paths` would be as specified in your config.
Expand Down
4 changes: 4 additions & 0 deletions packages/kit/src/runtime/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ export function create_client(app, target) {

/** @param {...string} pathnames */
async function preload_code(...pathnames) {
if (DEV && pathnames.length > 1) {
console.warn('Calling `preloadCode` with multiple arguments is deprecated');
}

const matching = routes.filter((route) => pathnames.some((pathname) => route.exec(pathname)));

const promises = matching.map((r) => {
Expand Down
3 changes: 2 additions & 1 deletion packages/kit/src/runtime/server/page/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ async function call_action(event, actions) {
}

if (!is_form_content_type(event.request)) {
throw new Error(
throw error(
415,
`Actions expect form-encoded data (received ${event.request.headers.get('content-type')})`
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/version.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// generated during release, do not modify

/** @type {string} */
export const VERSION = '1.28.0';
export const VERSION = '1.29.0';
15 changes: 15 additions & 0 deletions packages/kit/test/apps/basics/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,21 @@ test.describe('Actions', () => {

await expect(page.locator('pre')).toHaveText('something went wrong');
});

test('submitting application/json should return http status code 415', async ({ baseURL }) => {
const response = await fetch(`${baseURL}/actions/form-errors`, {
method: 'POST',
body: JSON.stringify({ foo: 'bar' }),
headers: {
'Content-Type': 'application/json',
Origin: `${baseURL}`
}
});
const { type, error } = await response.json();
expect(type).toBe('error');
expect(error.message).toBe('Actions expect form-encoded data (received application/json)');
expect(response.status).toBe(415);
});
});

// Run in serial to not pollute the log with (correct) cookie warnings
Expand Down
2 changes: 2 additions & 0 deletions packages/kit/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,8 @@ declare module '@sveltejs/kit' {
* If `true`, `base` and `assets` imported from `$app/paths` will be replaced with relative asset paths during server-side rendering, resulting in more portable HTML.
* If `false`, `%sveltekit.assets%` and references to build artifacts will always be root-relative paths, unless `paths.assets` is an external URL
*
* [Single-page app](https://kit.svelte.dev/docs/single-page-apps) fallback pages will always use absolute paths, regardless of this setting.
*
* If your app uses a `<base>` element, you should set this to `false`, otherwise asset URLs will incorrectly be resolved against the `<base>` URL rather than the current page.
*
* In 1.0, `undefined` was a valid value, which was set by default. In that case, if `paths.assets` was not external, SvelteKit would replace `%sveltekit.assets%` with a relative path and use relative paths to reference build artifacts, but `base` and `assets` imported from `$app/paths` would be as specified in your config.
Expand Down

0 comments on commit 63ad25a

Please sign in to comment.