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