Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/clean-countries-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Set `$page.url` to current URL in browser
1 change: 1 addition & 0 deletions packages/adapter-static/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
},
"devDependencies": {
"@sveltejs/kit": "workspace:*",
"devalue": "^2.0.1",
"playwright-chromium": "^1.17.0",
"port-authority": "^1.1.2",
"sirv": "^2.0.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/adapter-static/test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export function run(app, callback) {
suite.before(async (context) => {
try {
const cwd = fileURLToPath(new URL(`apps/${app}`, import.meta.url));
const cli_path = fileURLToPath(new URL('../../kit/dist/cli.js', import.meta.url));
const mode = process.env.CI ? 'dist' : 'src';
const cli_path = fileURLToPath(new URL(`../../kit/${mode}/cli.js`, import.meta.url));

rimraf(`${cwd}/build`);

Expand Down
8 changes: 3 additions & 5 deletions packages/kit/src/runtime/client/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,12 @@ export class Renderer {
* status: number;
* error: Error;
* nodes: Array<Promise<CSRComponent>>;
* url: URL;
* params: Record<string, string>;
* }} selected
*/
async start({ status, error, nodes, url, params }) {
async start({ status, error, nodes, params }) {
const url = new URL(location.href);

/** @type {Array<import('./types').BranchNode | undefined>} */
const branch = [];

Expand All @@ -211,9 +212,6 @@ export class Renderer {

let error_args;

// url.hash is empty when coming from the server
url.hash = window.location.hash;

try {
for (let i = 0; i < nodes.length; i += 1) {
const is_leaf = i === nodes.length - 1;
Expand Down
1 change: 0 additions & 1 deletion packages/kit/src/runtime/client/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { set_paths } from '../paths.js';
* status: number;
* error: Error;
* nodes: Array<Promise<import('types/internal').CSRComponent>>;
* url: URL;
* params: Record<string, string>;
* };
* }} opts
Expand Down
1 change: 0 additions & 1 deletion packages/kit/src/runtime/server/page/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ export async function render_response({
.map(({ node }) => `import(${s(options.prefix + node.entry)})`)
.join(',\n\t\t\t\t\t\t')}
],
url: new URL(${s(url.href)}),
params: ${devalue(params)}
}` : 'null'}
});
Expand Down
2 changes: 0 additions & 2 deletions packages/kit/test/prerendering/options/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ const read = (file) => fs.readFileSync(`${build}/${file}`, 'utf-8');
test('prerenders /path-base', () => {
const content = read('index.html');
assert.ok(content.includes('<h1>hello</h1>'));
assert.ok(content.includes('http://sveltekit-prerender/path-base'));
});

test('prerenders nested /path-base', () => {
const content = read('nested/index.html');
assert.ok(content.includes('<h1>nested hello</h1>'));
assert.ok(content.includes('http://sveltekit-prerender/path-base/nested'));
});

test('adds CSP headers via meta tag', () => {
Expand Down
2 changes: 2 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.