@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.
- package/build/cjs/path.js +9 -4
- package/build/cjs/path.js.map +1 -1
- package/build/cjs/router.js +10 -8
- package/build/cjs/router.js.map +1 -1
- package/build/esm/index.js +19 -12
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +132 -132
- package/build/types/index.d.ts +2 -2
- package/build/umd/index.development.js +19 -12
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/path.ts +10 -2
- package/src/router.ts +15 -10
package/build/esm/index.js
CHANGED
|
@@ -203,8 +203,8 @@ function interpolatePath(path, params, leaveWildcard) {
|
|
|
203
203
|
return segment.value;
|
|
204
204
|
}));
|
|
205
205
|
}
|
|
206
|
-
function matchPathname(currentPathname, matchLocation) {
|
|
207
|
-
const pathParams = matchByPath(currentPathname, matchLocation);
|
|
206
|
+
function matchPathname(basepath, currentPathname, matchLocation) {
|
|
207
|
+
const pathParams = matchByPath(basepath, currentPathname, matchLocation);
|
|
208
208
|
// const searchMatched = matchBySearch(currentLocation.search, matchLocation)
|
|
209
209
|
|
|
210
210
|
if (matchLocation.to && !pathParams) {
|
|
@@ -212,10 +212,15 @@ function matchPathname(currentPathname, matchLocation) {
|
|
|
212
212
|
}
|
|
213
213
|
return pathParams != null ? pathParams : {};
|
|
214
214
|
}
|
|
215
|
-
function matchByPath(from, matchLocation) {
|
|
215
|
+
function matchByPath(basepath, from, matchLocation) {
|
|
216
216
|
var _matchLocation$to;
|
|
217
|
+
if (basepath && !from.startsWith(basepath)) {
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
220
|
+
from = from.startsWith(basepath) ? from.substring(basepath.length) : from;
|
|
217
221
|
const baseSegments = parsePathname(from);
|
|
218
|
-
const
|
|
222
|
+
const to = "" + ((_matchLocation$to = matchLocation.to) != null ? _matchLocation$to : '*');
|
|
223
|
+
const routeSegments = parsePathname(to);
|
|
219
224
|
const params = {};
|
|
220
225
|
let isMatch = (() => {
|
|
221
226
|
for (let i = 0; i < Math.max(baseSegments.length, routeSegments.length); i++) {
|
|
@@ -826,7 +831,7 @@ function createRouter(userOptions) {
|
|
|
826
831
|
});
|
|
827
832
|
},
|
|
828
833
|
mount: () => {
|
|
829
|
-
|
|
834
|
+
router.__.buildLocation({
|
|
830
835
|
to: '.',
|
|
831
836
|
search: true,
|
|
832
837
|
hash: true
|
|
@@ -834,9 +839,10 @@ function createRouter(userOptions) {
|
|
|
834
839
|
|
|
835
840
|
// If the current location isn't updated, trigger a navigation
|
|
836
841
|
// to the current location. Otherwise, load the current location.
|
|
837
|
-
if (next.href !== router.__location.href) {
|
|
838
|
-
|
|
839
|
-
}
|
|
842
|
+
// if (next.href !== router.__location.href) {
|
|
843
|
+
// router.__.commitLocation(next, true)
|
|
844
|
+
// }
|
|
845
|
+
|
|
840
846
|
if (!router.state.matches.length) {
|
|
841
847
|
router.load();
|
|
842
848
|
}
|
|
@@ -864,6 +870,7 @@ function createRouter(userOptions) {
|
|
|
864
870
|
router.load();
|
|
865
871
|
},
|
|
866
872
|
update: opts => {
|
|
873
|
+
var _trimPath;
|
|
867
874
|
const newHistory = (opts == null ? void 0 : opts.history) !== router.history;
|
|
868
875
|
if (!router.__location || newHistory) {
|
|
869
876
|
if (opts != null && opts.history) {
|
|
@@ -877,7 +884,7 @@ function createRouter(userOptions) {
|
|
|
877
884
|
basepath,
|
|
878
885
|
routeConfig
|
|
879
886
|
} = router.options;
|
|
880
|
-
router.basepath =
|
|
887
|
+
router.basepath = "/" + ((_trimPath = trimPath(basepath != null ? basepath : '')) != null ? _trimPath : '');
|
|
881
888
|
if (routeConfig) {
|
|
882
889
|
router.routesById = {};
|
|
883
890
|
router.routeTree = router.__.buildRouteTree(routeConfig);
|
|
@@ -1075,7 +1082,7 @@ function createRouter(userOptions) {
|
|
|
1075
1082
|
return findMatchInRoutes([...foundRoutes, route], route.childRoutes);
|
|
1076
1083
|
}
|
|
1077
1084
|
const fuzzy = !!(route.routePath !== '/' || (_route$childRoutes2 = route.childRoutes) != null && _route$childRoutes2.length);
|
|
1078
|
-
const matchParams = matchPathname(pathname, {
|
|
1085
|
+
const matchParams = matchPathname(router.basepath, pathname, {
|
|
1079
1086
|
to: route.fullPath,
|
|
1080
1087
|
fuzzy,
|
|
1081
1088
|
caseSensitive: (_route$options$caseSe = route.options.caseSensitive) != null ? _route$options$caseSe : router.options.caseSensitive
|
|
@@ -1213,11 +1220,11 @@ function createRouter(userOptions) {
|
|
|
1213
1220
|
if (!((_router$state$pending7 = router.state.pending) != null && _router$state$pending7.location)) {
|
|
1214
1221
|
return false;
|
|
1215
1222
|
}
|
|
1216
|
-
return !!matchPathname(router.state.pending.location.pathname, _extends({}, opts, {
|
|
1223
|
+
return !!matchPathname(router.basepath, router.state.pending.location.pathname, _extends({}, opts, {
|
|
1217
1224
|
to: next.pathname
|
|
1218
1225
|
}));
|
|
1219
1226
|
}
|
|
1220
|
-
return !!matchPathname(router.state.location.pathname, _extends({}, opts, {
|
|
1227
|
+
return !!matchPathname(router.basepath, router.state.location.pathname, _extends({}, opts, {
|
|
1221
1228
|
to: next.pathname
|
|
1222
1229
|
}));
|
|
1223
1230
|
},
|