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

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 (basepath && !from.startsWith(basepath)) {
1035
+ return undefined;
1036
+ }
1037
+ from = from.startsWith(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);
@@ -1892,7 +1899,7 @@
1892
1899
  return findMatchInRoutes([...foundRoutes, route], route.childRoutes);
1893
1900
  }
1894
1901
  const fuzzy = !!(route.routePath !== '/' || (_route$childRoutes2 = route.childRoutes) != null && _route$childRoutes2.length);
1895
- const matchParams = matchPathname(pathname, {
1902
+ const matchParams = matchPathname(router.basepath, pathname, {
1896
1903
  to: route.fullPath,
1897
1904
  fuzzy,
1898
1905
  caseSensitive: (_route$options$caseSe = route.options.caseSensitive) != null ? _route$options$caseSe : router.options.caseSensitive
@@ -2030,11 +2037,11 @@
2030
2037
  if (!((_router$state$pending7 = router.state.pending) != null && _router$state$pending7.location)) {
2031
2038
  return false;
2032
2039
  }
2033
- return !!matchPathname(router.state.pending.location.pathname, _extends({}, opts, {
2040
+ return !!matchPathname(router.basepath, router.state.pending.location.pathname, _extends({}, opts, {
2034
2041
  to: next.pathname
2035
2042
  }));
2036
2043
  }
2037
- return !!matchPathname(router.state.location.pathname, _extends({}, opts, {
2044
+ return !!matchPathname(router.basepath, router.state.location.pathname, _extends({}, opts, {
2038
2045
  to: next.pathname
2039
2046
  }));
2040
2047
  },