@sveltejs/kit 1.0.0-next.260 → 1.0.0-next.261

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.
@@ -189,8 +189,11 @@ class Router {
189
189
  // Ignore if <a> has a target
190
190
  if (a instanceof SVGAElement ? a.target.baseVal : a.target) return;
191
191
 
192
- // Check if new url only differs by hash
193
- if (url.href.split('#')[0] === location.href.split('#')[0]) {
192
+ // Check if new url only differs by hash and use the browser default behavior in that case
193
+ // This will ensure the `hashchange` event is fired
194
+ // Removing the hash does a full page navigation in the browser, so make sure a hash is present
195
+ const [base, hash] = url.href.split('#');
196
+ if (hash !== undefined && base === location.href.split('#')[0]) {
194
197
  // Call `pushState` to add url to history so going back works.
195
198
  // Also make a delay, otherwise the browser default behaviour would not kick in
196
199
  setTimeout(() => history.pushState({}, '', url.href));
@@ -1266,11 +1269,14 @@ class Renderer {
1266
1269
  let props = {};
1267
1270
 
1268
1271
  if (has_shadow && i === a.length - 1) {
1269
- const res = await fetch(`${url.pathname}/__data.json`, {
1270
- headers: {
1271
- 'x-sveltekit-noredirect': 'true'
1272
+ const res = await fetch(
1273
+ `${url.pathname}${url.pathname.endsWith('/') ? '' : '/'}__data.json`,
1274
+ {
1275
+ headers: {
1276
+ 'x-sveltekit-noredirect': 'true'
1277
+ }
1272
1278
  }
1273
- });
1279
+ );
1274
1280
 
1275
1281
  if (res.ok) {
1276
1282
  const redirect = res.headers.get('x-sveltekit-location');
@@ -474,8 +474,7 @@ function coalesce_to_error(err) {
474
474
  }
475
475
 
476
476
  /** @type {Record<string, string>} */
477
- const escape_json_string_in_html_dict = {
478
- '"': '\\"',
477
+ const escape_json_in_html_dict = {
479
478
  '<': '\\u003C',
480
479
  '>': '\\u003E',
481
480
  '/': '\\u002F',
@@ -490,7 +489,24 @@ const escape_json_string_in_html_dict = {
490
489
  '\u2029': '\\u2029'
491
490
  };
492
491
 
493
- /** @param {string} str */
492
+ /** @type {Record<string, string>} */
493
+ const escape_json_string_in_html_dict = {
494
+ '"': '\\"',
495
+ ...escape_json_in_html_dict
496
+ };
497
+
498
+ /**
499
+ * Escape a stringified JSON object that's going to be embedded in a `<script>` tag
500
+ * @param {string} str
501
+ */
502
+ function escape_json_in_html(str) {
503
+ return escape(str, escape_json_in_html_dict, (code) => `\\u${code.toString(16).toUpperCase()}`);
504
+ }
505
+
506
+ /**
507
+ * Escape a string JSON value to be embedded into a `<script>` tag
508
+ * @param {string} str
509
+ */
494
510
  function escape_json_string_in_html(str) {
495
511
  return escape(
496
512
  str,
@@ -1269,7 +1285,7 @@ async function render_response({
1269
1285
 
1270
1286
  if (shadow_props) {
1271
1287
  // prettier-ignore
1272
- body += `<script type="application/json" data-type="svelte-props">${s(shadow_props)}</script>`;
1288
+ body += `<script type="application/json" data-type="svelte-props">${escape_json_in_html(s(shadow_props))}</script>`;
1273
1289
  }
1274
1290
  }
1275
1291
 
package/dist/cli.js CHANGED
@@ -995,7 +995,7 @@ async function launch(port, https) {
995
995
  exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
996
996
  }
997
997
 
998
- const prog = sade('svelte-kit').version('1.0.0-next.260');
998
+ const prog = sade('svelte-kit').version('1.0.0-next.261');
999
999
 
1000
1000
  prog
1001
1001
  .command('dev')
@@ -1153,7 +1153,7 @@ async function check_port(port) {
1153
1153
  function welcome({ port, host, https, open, loose, allow, cwd }) {
1154
1154
  if (open) launch(port, https);
1155
1155
 
1156
- console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.260'}\n`));
1156
+ console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.261'}\n`));
1157
1157
 
1158
1158
  const protocol = https ? 'https:' : 'http:';
1159
1159
  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.260",
3
+ "version": "1.0.0-next.261",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",