-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] browser only redirect during load (#2462)
- Loading branch information
1 parent
6ba7e1c
commit b61acee
Showing
6 changed files
with
50 additions
and
1 deletion.
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,5 @@ | ||
--- | ||
'@sveltejs/kit': patch | ||
--- | ||
|
||
fix browser-only redirect during load. |
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
13 changes: 13 additions & 0 deletions
13
packages/kit/test/apps/basics/src/routes/redirect-on-load/_tests.js
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,13 @@ | ||
import * as assert from 'uvu/assert'; | ||
|
||
/** @type {import('test').TestMaker} */ | ||
export default function (test) { | ||
test('redirect-on-load', '/redirect-on-load', async ({ base, page, js }) => { | ||
if (js) { | ||
assert.equal(page.url(), `${base}/redirect-on-load/redirected`); | ||
assert.equal(await page.textContent('h1'), 'Hazaa!'); | ||
} else { | ||
assert.equal(page.url(), `${base}/redirect-on-load`); | ||
} | ||
}); | ||
} |
17 changes: 17 additions & 0 deletions
17
packages/kit/test/apps/basics/src/routes/redirect-on-load/index.svelte
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,17 @@ | ||
<script context="module"> | ||
import { browser } from '$app/env'; | ||
export async function load() { | ||
if (browser) { | ||
return { | ||
status: 303, | ||
redirect: '/redirect-on-load/redirected' | ||
}; | ||
} | ||
return {}; | ||
} | ||
</script> | ||
|
||
<h1>Woops!</h1> | ||
<p>You shouldn't be here. You should have been directed to /redirect!</p> |
1 change: 1 addition & 0 deletions
1
packages/kit/test/apps/basics/src/routes/redirect-on-load/redirected.svelte
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 @@ | ||
<h1>Hazaa!</h1> |
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