@sveltejs/kit 1.0.0-next.271 → 1.0.0-next.272

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.
@@ -83,6 +83,8 @@ class Router {
83
83
  history.replaceState({ ...history.state, 'sveltekit:index': 0 }, '', location.href);
84
84
  }
85
85
 
86
+ this.hash_navigating = false;
87
+
86
88
  this.callbacks = {
87
89
  /** @type {Array<({ from, to, cancel }: { from: URL, to: URL | null, cancel: () => void }) => void>} */
88
90
  before_navigate: [],
@@ -210,9 +212,8 @@ class Router {
210
212
  // Removing the hash does a full page navigation in the browser, so make sure a hash is present
211
213
  const [base, hash] = url.href.split('#');
212
214
  if (hash !== undefined && base === location.href.split('#')[0]) {
213
- // Call `pushState` to add url to history so going back works.
214
- // Also make a delay, otherwise the browser default behaviour would not kick in
215
- setTimeout(() => history.pushState({}, '', url.href));
215
+ this.hash_navigating = true;
216
+
216
217
  const info = this.parse(url);
217
218
  if (info) {
218
219
  return this.renderer.update(info, [], false);
@@ -256,6 +257,17 @@ class Router {
256
257
  });
257
258
  }
258
259
  });
260
+
261
+ addEventListener('hashchange', () => {
262
+ if (this.hash_navigating) {
263
+ this.hash_navigating = false;
264
+ history.replaceState(
265
+ { ...history.state, 'sveltekit:index': ++this.current_history_index },
266
+ '',
267
+ location.href
268
+ );
269
+ }
270
+ });
259
271
  }
260
272
 
261
273
  /**
@@ -1279,7 +1291,7 @@ class Renderer {
1279
1291
 
1280
1292
  if (has_shadow && i === a.length - 1) {
1281
1293
  const res = await fetch(
1282
- `${url.pathname}${url.pathname.endsWith('/') ? '' : '/'}__data.json`,
1294
+ `${url.pathname}${url.pathname.endsWith('/') ? '' : '/'}__data.json${url.search}`,
1283
1295
  {
1284
1296
  headers: {
1285
1297
  'x-sveltekit-load': 'true'
@@ -2602,7 +2602,17 @@ async function respond(request, options, state = {}) {
2602
2602
  }
2603
2603
 
2604
2604
  const is_data_request = decoded.endsWith(DATA_SUFFIX);
2605
- if (is_data_request) decoded = decoded.slice(0, -DATA_SUFFIX.length) || '/';
2605
+
2606
+ if (is_data_request) {
2607
+ decoded = decoded.slice(0, -DATA_SUFFIX.length) || '/';
2608
+
2609
+ const normalized = normalize_path(
2610
+ url.pathname.slice(0, -DATA_SUFFIX.length),
2611
+ options.trailing_slash
2612
+ );
2613
+
2614
+ event.url = new URL(event.url.origin + normalized + event.url.search);
2615
+ }
2606
2616
 
2607
2617
  for (const route of options.manifest._.routes) {
2608
2618
  const match = route.pattern.exec(decoded);
package/dist/cli.js CHANGED
@@ -998,7 +998,7 @@ async function launch(port, https) {
998
998
  exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
999
999
  }
1000
1000
 
1001
- const prog = sade('svelte-kit').version('1.0.0-next.271');
1001
+ const prog = sade('svelte-kit').version('1.0.0-next.272');
1002
1002
 
1003
1003
  prog
1004
1004
  .command('dev')
@@ -1156,7 +1156,7 @@ async function check_port(port) {
1156
1156
  function welcome({ port, host, https, open, loose, allow, cwd }) {
1157
1157
  if (open) launch(port, https);
1158
1158
 
1159
- console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.271'}\n`));
1159
+ console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.272'}\n`));
1160
1160
 
1161
1161
  const protocol = https ? 'https:' : 'http:';
1162
1162
  const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.271",
3
+ "version": "1.0.0-next.272",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",