@tanstack/react-router 1.87.9 → 1.88.0

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.
@@ -574,9 +574,9 @@ class Router {
574
574
  resetScroll,
575
575
  viewTransition,
576
576
  ignoreBlocker,
577
+ href,
577
578
  ...rest
578
579
  } = {}) => {
579
- const href = rest.href;
580
580
  if (href) {
581
581
  const parsed = history.parseHref(href, {});
582
582
  rest.to = parsed.pathname;
@@ -595,22 +595,23 @@ class Router {
595
595
  ignoreBlocker
596
596
  });
597
597
  };
598
- this.navigate = ({ to, ...rest }) => {
599
- const toString = String(to);
600
- let isExternal;
601
- try {
602
- new URL(`${toString}`);
603
- isExternal = true;
604
- } catch (e) {
598
+ this.navigate = ({ to, reloadDocument, href, ...rest }) => {
599
+ if (reloadDocument) {
600
+ if (!href) {
601
+ const location = this.buildLocation({ to, ...rest });
602
+ href = location.href;
603
+ }
604
+ if (rest.replace) {
605
+ window.location.replace(href);
606
+ } else {
607
+ window.location.href = href;
608
+ }
609
+ return;
605
610
  }
606
- invariant(
607
- !isExternal,
608
- "Attempting to navigate to external url with router.navigate!"
609
- );
610
611
  return this.buildAndCommitLocation({
611
612
  ...rest,
613
+ href,
612
614
  to
613
- // to: toString,
614
615
  });
615
616
  };
616
617
  this.load = async () => {
@@ -712,7 +713,7 @@ class Router {
712
713
  redirect = err;
713
714
  if (!this.isServer) {
714
715
  this.navigate({
715
- ...err,
716
+ ...redirect,
716
717
  replace: true,
717
718
  ignoreBlocker: true
718
719
  });
@@ -808,7 +809,11 @@ class Router {
808
809
  }
809
810
  const handleRedirectAndNotFound = (match, err) => {
810
811
  var _a, _b, _c;
811
- if (redirects.isResolvedRedirect(err)) throw err;
812
+ if (redirects.isResolvedRedirect(err)) {
813
+ if (!err.reloadDocument) {
814
+ throw err;
815
+ }
816
+ }
812
817
  if (redirects.isRedirect(err) || notFound.isNotFound(err)) {
813
818
  updateMatch(match.id, (prev) => ({
814
819
  ...prev,
@@ -1292,6 +1297,9 @@ class Router {
1292
1297
  return matches;
1293
1298
  } catch (err) {
1294
1299
  if (redirects.isRedirect(err)) {
1300
+ if (err.reloadDocument) {
1301
+ return void 0;
1302
+ }
1295
1303
  return await this.preloadRoute({
1296
1304
  ...err,
1297
1305
  _fromLocation: next