Skip to content

Commit

Permalink
[fix] don't use client-side router for same path on different origin (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Conduitry authored Mar 23, 2022
1 parent e338edc commit c040255
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/kind-ducks-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

[fix] don't use client-side navigation when clicking on a link to the same path on a different origin
6 changes: 5 additions & 1 deletion packages/kit/src/runtime/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,11 @@ export function create_client({ target, session, base, trailing_slash }) {
const current_token = (token = {});
let navigation_result = intent && (await load_route(intent, no_cache));

if (!navigation_result && url.pathname === location.pathname) {
if (
!navigation_result &&
url.origin === location.origin &&
url.pathname === location.pathname
) {
// this could happen in SPA fallback mode if the user navigated to
// `/non-existent-page`. if we fall back to reloading the page, it
// will create an infinite loop. so whereas we normally handle
Expand Down

0 comments on commit c040255

Please sign in to comment.