From d28abad4291ce96365250b92e7290bc150073f91 Mon Sep 17 00:00:00 2001 From: Mihael Date: Sat, 5 Feb 2022 20:10:40 +0100 Subject: [PATCH 1/4] fix #3718 shadow endpoint fetching if path ends with '/' --- packages/kit/src/runtime/client/renderer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/kit/src/runtime/client/renderer.js b/packages/kit/src/runtime/client/renderer.js index 024fcc1451bb..64f2413f9b45 100644 --- a/packages/kit/src/runtime/client/renderer.js +++ b/packages/kit/src/runtime/client/renderer.js @@ -753,7 +753,7 @@ export class Renderer { let props = {}; if (has_shadow && i === a.length - 1) { - const res = await fetch(`${url.pathname}/__data.json`, { + const res = await fetch(`${url.pathname}${url.pathname.endsWith('/') ? '' : '/'}__data.json`, { headers: { 'x-sveltekit-noredirect': 'true' } From a6caf6e878972839d2c226fe3fd681e6552e19bc Mon Sep 17 00:00:00 2001 From: Mihael Date: Sat, 5 Feb 2022 20:18:23 +0100 Subject: [PATCH 2/4] format and lint --- packages/kit/src/runtime/client/renderer.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/kit/src/runtime/client/renderer.js b/packages/kit/src/runtime/client/renderer.js index 64f2413f9b45..c85fa5e23dd8 100644 --- a/packages/kit/src/runtime/client/renderer.js +++ b/packages/kit/src/runtime/client/renderer.js @@ -753,11 +753,14 @@ export class Renderer { let props = {}; if (has_shadow && i === a.length - 1) { - const res = await fetch(`${url.pathname}${url.pathname.endsWith('/') ? '' : '/'}__data.json`, { - headers: { - 'x-sveltekit-noredirect': 'true' + const res = await fetch( + `${url.pathname}${url.pathname.endsWith('/') ? '' : '/'}__data.json`, + { + headers: { + 'x-sveltekit-noredirect': 'true' + } } - }); + ); if (res.ok) { const redirect = res.headers.get('x-sveltekit-location'); From 2d18bfd062b49a2cc31214da592254864e0fd3e5 Mon Sep 17 00:00:00 2001 From: Mihael Date: Sat, 5 Feb 2022 20:23:34 +0100 Subject: [PATCH 3/4] added changeset --- .changeset/mighty-cycles-double.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/mighty-cycles-double.md diff --git a/.changeset/mighty-cycles-double.md b/.changeset/mighty-cycles-double.md new file mode 100644 index 000000000000..ef15b25b4305 --- /dev/null +++ b/.changeset/mighty-cycles-double.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fixes an error with fetching shadow endpoints if they are ending with '/' From 7193b601dde8e1493fd06b8d84e9b89f71a52265 Mon Sep 17 00:00:00 2001 From: Mihael Date: Sun, 6 Feb 2022 18:40:53 +0100 Subject: [PATCH 4/4] .