@sveltejs/kit 2.0.0 → 2.0.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "The fastest way to build Svelte apps",
5
5
  "repository": {
6
6
  "type": "git",
@@ -660,10 +660,10 @@ export function create_client(app, target) {
660
660
  server: server_data_node,
661
661
  universal: node.universal?.load ? { type: 'data', data, uses } : null,
662
662
  data: data ?? server_data_node?.data ?? null,
663
- // if `paths.base === '/a/b/c`, then the root route is `/a/b/c/`,
664
- // regardless of the `trailingSlash` route option
663
+ // if `paths.base === '/a/b/c`, then the root route is always `/a/b/c/`, regardless of
664
+ // the `trailingSlash` route option, so that relative paths to JS and CSS work
665
665
  slash:
666
- url.pathname === base || url.pathname === base + '/'
666
+ base && (url.pathname === base || url.pathname === base + '/')
667
667
  ? 'always'
668
668
  : node.universal?.trailingSlash ?? server_data_node?.slash
669
669
  };
@@ -2118,16 +2118,21 @@ async function load_data(url, invalid) {
2118
2118
 
2119
2119
  const res = await native_fetch(data_url.href);
2120
2120
 
2121
- // if `__data.json` doesn't exist or the server has an internal error,
2122
- // fallback to native navigation so we avoid parsing the HTML error page as a JSON
2123
- if (res.headers.get('content-type')?.includes('text/html')) {
2124
- await native_navigation(url);
2125
- }
2126
-
2127
2121
  if (!res.ok) {
2128
2122
  // error message is a JSON-stringified string which devalue can't handle at the top level
2129
2123
  // turn it into a HttpError to not call handleError on the client again (was already handled on the server)
2130
- throw new HttpError(res.status, await res.json());
2124
+ // if `__data.json` doesn't exist or the server has an internal error,
2125
+ // avoid parsing the HTML error page as a JSON
2126
+ /** @type {string | undefined} */
2127
+ let message;
2128
+ if (res.headers.get('content-type')?.includes('application/json')) {
2129
+ message = await res.json();
2130
+ } else if (res.status === 404) {
2131
+ message = 'Not Found';
2132
+ } else if (res.status === 500) {
2133
+ message = 'Internal Error';
2134
+ }
2135
+ throw new HttpError(res.status, message);
2131
2136
  }
2132
2137
 
2133
2138
  // TODO: fix eslint error / figure out if it actually applies to our situation
@@ -33,6 +33,7 @@ export class Redirect {
33
33
  /**
34
34
  * An error that was thrown from within the SvelteKit runtime that is not fatal and doesn't result in a 500, such as a 404.
35
35
  * `SvelteKitError` goes through `handleError`.
36
+ * @extends Error
36
37
  */
37
38
  export class SvelteKitError extends Error {
38
39
  /**
@@ -86,7 +86,7 @@ export async function respond_with_error({
86
86
  state,
87
87
  page_config: {
88
88
  ssr,
89
- csr: get_option([default_layout], 'csr') ?? true
89
+ csr
90
90
  },
91
91
  status,
92
92
  error: await handle_error_and_jsonify(event, options, error),
package/src/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // generated during release, do not modify
2
2
 
3
3
  /** @type {string} */
4
- export const VERSION = '2.0.0';
4
+ export const VERSION = '2.0.2';