@tanstack/router-core 0.0.1-beta.33 → 0.0.1-beta.35

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.
@@ -1020,8 +1020,8 @@
1020
1020
  return segment.value;
1021
1021
  }));
1022
1022
  }
1023
- function matchPathname(currentPathname, matchLocation) {
1024
- const pathParams = matchByPath(currentPathname, matchLocation);
1023
+ function matchPathname(basepath, currentPathname, matchLocation) {
1024
+ const pathParams = matchByPath(basepath, currentPathname, matchLocation);
1025
1025
  // const searchMatched = matchBySearch(currentLocation.search, matchLocation)
1026
1026
 
1027
1027
  if (matchLocation.to && !pathParams) {
@@ -1029,10 +1029,15 @@
1029
1029
  }
1030
1030
  return pathParams != null ? pathParams : {};
1031
1031
  }
1032
- function matchByPath(from, matchLocation) {
1032
+ function matchByPath(basepath, from, matchLocation) {
1033
1033
  var _matchLocation$to;
1034
+ if (!from.startsWith(basepath)) {
1035
+ return undefined;
1036
+ }
1037
+ from = basepath != '/' ? from.substring(basepath.length) : from;
1034
1038
  const baseSegments = parsePathname(from);
1035
- const routeSegments = parsePathname("" + ((_matchLocation$to = matchLocation.to) != null ? _matchLocation$to : '*'));
1039
+ const to = "" + ((_matchLocation$to = matchLocation.to) != null ? _matchLocation$to : '*');
1040
+ const routeSegments = parsePathname(to);
1036
1041
  const params = {};
1037
1042
  let isMatch = (() => {
1038
1043
  for (let i = 0; i < Math.max(baseSegments.length, routeSegments.length); i++) {
@@ -1643,7 +1648,7 @@
1643
1648
  });
1644
1649
  },
1645
1650
  mount: () => {
1646
- const next = router.__.buildLocation({
1651
+ router.__.buildLocation({
1647
1652
  to: '.',
1648
1653
  search: true,
1649
1654
  hash: true
@@ -1651,9 +1656,10 @@
1651
1656
 
1652
1657
  // If the current location isn't updated, trigger a navigation
1653
1658
  // to the current location. Otherwise, load the current location.
1654
- if (next.href !== router.__location.href) {
1655
- router.__.commitLocation(next, true);
1656
- }
1659
+ // if (next.href !== router.__location.href) {
1660
+ // router.__.commitLocation(next, true)
1661
+ // }
1662
+
1657
1663
  if (!router.state.matches.length) {
1658
1664
  router.load();
1659
1665
  }
@@ -1681,6 +1687,7 @@
1681
1687
  router.load();
1682
1688
  },
1683
1689
  update: opts => {
1690
+ var _trimPath;
1684
1691
  const newHistory = (opts == null ? void 0 : opts.history) !== router.history;
1685
1692
  if (!router.__location || newHistory) {
1686
1693
  if (opts != null && opts.history) {
@@ -1694,7 +1701,7 @@
1694
1701
  basepath,
1695
1702
  routeConfig
1696
1703
  } = router.options;
1697
- router.basepath = cleanPath("/" + (basepath != null ? basepath : ''));
1704
+ router.basepath = "/" + ((_trimPath = trimPath(basepath != null ? basepath : '')) != null ? _trimPath : '');
1698
1705
  if (routeConfig) {
1699
1706
  router.routesById = {};
1700
1707
  router.routeTree = router.__.buildRouteTree(routeConfig);
@@ -1745,10 +1752,8 @@
1745
1752
  match
1746
1753
  })));
1747
1754
  } catch (err) {
1748
- if (err != null && err.then) {
1749
- await new Promise(() => {});
1750
- }
1751
- throw err;
1755
+ console.info(err);
1756
+ invariant(false, "A route's beforeLoad middleware failed! \uD83D\uDC46");
1752
1757
  }
1753
1758
  router.notify();
1754
1759
 
@@ -1892,11 +1897,12 @@
1892
1897
  return findMatchInRoutes([...foundRoutes, route], route.childRoutes);
1893
1898
  }
1894
1899
  const fuzzy = !!(route.routePath !== '/' || (_route$childRoutes2 = route.childRoutes) != null && _route$childRoutes2.length);
1895
- const matchParams = matchPathname(pathname, {
1900
+ const matchParams = matchPathname(router.basepath, pathname, {
1896
1901
  to: route.fullPath,
1897
1902
  fuzzy,
1898
1903
  caseSensitive: (_route$options$caseSe = route.options.caseSensitive) != null ? _route$options$caseSe : router.options.caseSensitive
1899
1904
  });
1905
+ console.log(router.basepath, route.fullPath, fuzzy, pathname, matchParams);
1900
1906
  if (matchParams) {
1901
1907
  let parsedParams;
1902
1908
  try {
@@ -2030,11 +2036,11 @@
2030
2036
  if (!((_router$state$pending7 = router.state.pending) != null && _router$state$pending7.location)) {
2031
2037
  return false;
2032
2038
  }
2033
- return !!matchPathname(router.state.pending.location.pathname, _extends({}, opts, {
2039
+ return !!matchPathname(router.basepath, router.state.pending.location.pathname, _extends({}, opts, {
2034
2040
  to: next.pathname
2035
2041
  }));
2036
2042
  }
2037
- return !!matchPathname(router.state.location.pathname, _extends({}, opts, {
2043
+ return !!matchPathname(router.basepath, router.state.location.pathname, _extends({}, opts, {
2038
2044
  to: next.pathname
2039
2045
  }));
2040
2046
  },