@remix-run/router 0.0.0-experimental-35fa15e5 → 0.0.0-experimental-8bb3ffdf
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/CHANGELOG.md +200 -0
- package/README.md +1 -1
- package/dist/router.cjs.js +124 -103
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.d.ts +8 -0
- package/dist/router.js +115 -98
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +124 -103
- package/dist/router.umd.js.map +1 -1
- package/dist/router.umd.min.js +2 -2
- package/dist/router.umd.min.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/package.json +1 -1
- package/router.ts +118 -78
- package/utils.ts +18 -30
package/dist/router.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v0.0.0-experimental-
|
|
2
|
+
* @remix-run/router v0.0.0-experimental-8bb3ffdf
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -1196,9 +1196,16 @@
|
|
|
1196
1196
|
|
|
1197
1197
|
// Return the array of pathnames for the current route matches - used to
|
|
1198
1198
|
// generate the routePathnames input for resolveTo()
|
|
1199
|
-
function getResolveToMatches(matches) {
|
|
1200
|
-
|
|
1201
|
-
|
|
1199
|
+
function getResolveToMatches(matches, v7_relativeSplatPath) {
|
|
1200
|
+
let pathMatches = getPathContributingMatches(matches);
|
|
1201
|
+
|
|
1202
|
+
// When v7_relativeSplatPath is enabled, use the full pathname for the leaf
|
|
1203
|
+
// match so we include splat values for "." links. See:
|
|
1204
|
+
// https://github.com/remix-run/react-router/issues/11052#issuecomment-1836589329
|
|
1205
|
+
if (v7_relativeSplatPath) {
|
|
1206
|
+
return pathMatches.map((match, idx) => idx === matches.length - 1 ? match.pathname : match.pathnameBase);
|
|
1207
|
+
}
|
|
1208
|
+
return pathMatches.map(match => match.pathnameBase);
|
|
1202
1209
|
}
|
|
1203
1210
|
|
|
1204
1211
|
/**
|
|
@@ -1232,37 +1239,21 @@
|
|
|
1232
1239
|
// to the current location's pathname and *not* the route pathname.
|
|
1233
1240
|
if (toPathname == null) {
|
|
1234
1241
|
from = locationPathname;
|
|
1235
|
-
} else if (isPathRelative) {
|
|
1236
|
-
let fromSegments = routePathnames[routePathnames.length - 1].replace(/^\//, "").split("/");
|
|
1237
|
-
if (toPathname.startsWith("..")) {
|
|
1238
|
-
let toSegments = toPathname.split("/");
|
|
1239
|
-
|
|
1240
|
-
// With relative="path", each leading .. segment means "go up one URL segment"
|
|
1241
|
-
while (toSegments[0] === "..") {
|
|
1242
|
-
toSegments.shift();
|
|
1243
|
-
fromSegments.pop();
|
|
1244
|
-
}
|
|
1245
|
-
to.pathname = toSegments.join("/");
|
|
1246
|
-
}
|
|
1247
|
-
from = "/" + fromSegments.join("/");
|
|
1248
1242
|
} else {
|
|
1249
1243
|
let routePathnameIndex = routePathnames.length - 1;
|
|
1250
|
-
if (toPathname.startsWith("..")) {
|
|
1251
|
-
let toSegments = toPathname.split("/");
|
|
1252
1244
|
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1245
|
+
// With relative="route" (the default), each leading .. segment means
|
|
1246
|
+
// "go up one route" instead of "go up one URL segment". This is a key
|
|
1247
|
+
// difference from how <a href> works and a major reason we call this a
|
|
1248
|
+
// "to" value instead of a "href".
|
|
1249
|
+
if (!isPathRelative && toPathname.startsWith("..")) {
|
|
1250
|
+
let toSegments = toPathname.split("/");
|
|
1257
1251
|
while (toSegments[0] === "..") {
|
|
1258
1252
|
toSegments.shift();
|
|
1259
1253
|
routePathnameIndex -= 1;
|
|
1260
1254
|
}
|
|
1261
1255
|
to.pathname = toSegments.join("/");
|
|
1262
1256
|
}
|
|
1263
|
-
|
|
1264
|
-
// If there are more ".." segments than parent routes, resolve relative to
|
|
1265
|
-
// the root / URL.
|
|
1266
1257
|
from = routePathnameIndex >= 0 ? routePathnames[routePathnameIndex] : "/";
|
|
1267
1258
|
}
|
|
1268
1259
|
let path = resolvePath(to, from);
|
|
@@ -1689,7 +1680,8 @@
|
|
|
1689
1680
|
v7_fetcherPersist: false,
|
|
1690
1681
|
v7_normalizeFormMethod: false,
|
|
1691
1682
|
v7_partialHydration: false,
|
|
1692
|
-
v7_prependBasename: false
|
|
1683
|
+
v7_prependBasename: false,
|
|
1684
|
+
v7_relativeSplatPath: false
|
|
1693
1685
|
}, init.future);
|
|
1694
1686
|
// Cleanup function for history
|
|
1695
1687
|
let unlistenHistory = null;
|
|
@@ -1725,18 +1717,28 @@
|
|
|
1725
1717
|
[route.id]: error
|
|
1726
1718
|
};
|
|
1727
1719
|
}
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1720
|
+
let initialized;
|
|
1721
|
+
let hasLazyRoutes = initialMatches.some(m => m.route.lazy);
|
|
1722
|
+
let hasLoaders = initialMatches.some(m => m.route.loader);
|
|
1723
|
+
if (hasLazyRoutes) {
|
|
1724
|
+
// All initialMatches need to be loaded before we're ready. If we have lazy
|
|
1725
|
+
// functions around still then we'll need to run them in initialize()
|
|
1726
|
+
initialized = false;
|
|
1727
|
+
} else if (!hasLoaders) {
|
|
1728
|
+
// If we've got no loaders to run, then we're good to go
|
|
1729
|
+
initialized = true;
|
|
1730
|
+
} else if (future.v7_partialHydration) {
|
|
1731
|
+
// If partial hydration is enabled, we're initialized so long as we were
|
|
1732
|
+
// provided with hydrationData for every route with a loader, and no loaders
|
|
1733
|
+
// were marked for explicit hydration
|
|
1734
|
+
let loaderData = init.hydrationData ? init.hydrationData.loaderData : null;
|
|
1735
|
+
let errors = init.hydrationData ? init.hydrationData.errors : null;
|
|
1736
|
+
initialized = initialMatches.every(m => m.route.loader && m.route.loader.hydrate !== true && (loaderData && loaderData[m.route.id] !== undefined || errors && errors[m.route.id] !== undefined));
|
|
1737
|
+
} else {
|
|
1738
|
+
// Without partial hydration - we're initialized if we were provided any
|
|
1739
|
+
// hydrationData - which is expected to be complete
|
|
1740
|
+
initialized = init.hydrationData != null;
|
|
1741
|
+
}
|
|
1740
1742
|
let router;
|
|
1741
1743
|
let state = {
|
|
1742
1744
|
historyAction: init.history.action,
|
|
@@ -1903,7 +1905,7 @@
|
|
|
1903
1905
|
// in the normal navigation flow. For SSR it's expected that lazy modules are
|
|
1904
1906
|
// resolved prior to router creation since we can't go into a fallbackElement
|
|
1905
1907
|
// UI for SSR'd apps
|
|
1906
|
-
if (!state.initialized
|
|
1908
|
+
if (!state.initialized) {
|
|
1907
1909
|
startNavigation(Action.Pop, state.location, {
|
|
1908
1910
|
initialHydration: true
|
|
1909
1911
|
});
|
|
@@ -2095,7 +2097,7 @@
|
|
|
2095
2097
|
init.history.go(to);
|
|
2096
2098
|
return;
|
|
2097
2099
|
}
|
|
2098
|
-
let normalizedPath = normalizeTo(state.location, state.matches, basename, future.v7_prependBasename, to, opts == null ? void 0 : opts.fromRouteId, opts == null ? void 0 : opts.relative);
|
|
2100
|
+
let normalizedPath = normalizeTo(state.location, state.matches, basename, future.v7_prependBasename, to, future.v7_relativeSplatPath, opts == null ? void 0 : opts.fromRouteId, opts == null ? void 0 : opts.relative);
|
|
2099
2101
|
let {
|
|
2100
2102
|
path,
|
|
2101
2103
|
submission,
|
|
@@ -2344,7 +2346,7 @@
|
|
|
2344
2346
|
})
|
|
2345
2347
|
};
|
|
2346
2348
|
} else {
|
|
2347
|
-
result = await callLoaderOrAction("action", request, actionMatch, matches, manifest, mapRouteProperties, basename);
|
|
2349
|
+
result = await callLoaderOrAction("action", request, actionMatch, matches, manifest, mapRouteProperties, basename, future.v7_relativeSplatPath);
|
|
2348
2350
|
if (request.signal.aborted) {
|
|
2349
2351
|
return {
|
|
2350
2352
|
shortCircuited: true
|
|
@@ -2554,7 +2556,7 @@
|
|
|
2554
2556
|
if (fetchControllers.has(key)) abortFetcher(key);
|
|
2555
2557
|
let flushSync = (opts && opts.unstable_flushSync) === true;
|
|
2556
2558
|
let routesToUse = inFlightDataRoutes || dataRoutes;
|
|
2557
|
-
let normalizedPath = normalizeTo(state.location, state.matches, basename, future.v7_prependBasename, href, routeId, opts == null ? void 0 : opts.relative);
|
|
2559
|
+
let normalizedPath = normalizeTo(state.location, state.matches, basename, future.v7_prependBasename, href, future.v7_relativeSplatPath, routeId, opts == null ? void 0 : opts.relative);
|
|
2558
2560
|
let matches = matchRoutes(routesToUse, normalizedPath, basename);
|
|
2559
2561
|
if (!matches) {
|
|
2560
2562
|
setFetcherError(key, routeId, getInternalRouterError(404, {
|
|
@@ -2619,7 +2621,7 @@
|
|
|
2619
2621
|
let fetchRequest = createClientSideRequest(init.history, path, abortController.signal, submission);
|
|
2620
2622
|
fetchControllers.set(key, abortController);
|
|
2621
2623
|
let originatingLoadId = incrementingLoadId;
|
|
2622
|
-
let actionResult = await callLoaderOrAction("action", fetchRequest, match, requestMatches, manifest, mapRouteProperties, basename);
|
|
2624
|
+
let actionResult = await callLoaderOrAction("action", fetchRequest, match, requestMatches, manifest, mapRouteProperties, basename, future.v7_relativeSplatPath);
|
|
2623
2625
|
if (fetchRequest.signal.aborted) {
|
|
2624
2626
|
// We can delete this so long as we weren't aborted by our own fetcher
|
|
2625
2627
|
// re-submit which would have put _new_ controller is in fetchControllers
|
|
@@ -2628,32 +2630,40 @@
|
|
|
2628
2630
|
}
|
|
2629
2631
|
return;
|
|
2630
2632
|
}
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
if (
|
|
2636
|
-
|
|
2637
|
-
if (pendingNavigationLoadId > originatingLoadId) {
|
|
2638
|
-
// A new navigation was kicked off after our action started, so that
|
|
2639
|
-
// should take precedence over this redirect navigation. We already
|
|
2640
|
-
// set isRevalidationRequired so all loaders for the new route should
|
|
2641
|
-
// fire unless opted out via shouldRevalidate
|
|
2633
|
+
|
|
2634
|
+
// When using v7_fetcherPersist, we don't want errors bubbling up to the UI
|
|
2635
|
+
// or redirects processed for unmounted fetchers so we just revert them to
|
|
2636
|
+
// idle
|
|
2637
|
+
if (future.v7_fetcherPersist && deletedFetchers.has(key)) {
|
|
2638
|
+
if (isRedirectResult(actionResult) || isErrorResult(actionResult)) {
|
|
2642
2639
|
updateFetcherState(key, getDoneFetcher(undefined));
|
|
2643
2640
|
return;
|
|
2644
|
-
} else {
|
|
2645
|
-
fetchRedirectIds.add(key);
|
|
2646
|
-
updateFetcherState(key, getLoadingFetcher(submission));
|
|
2647
|
-
return startRedirectNavigation(state, actionResult, {
|
|
2648
|
-
fetcherSubmission: submission
|
|
2649
|
-
});
|
|
2650
2641
|
}
|
|
2651
|
-
|
|
2642
|
+
// Let SuccessResult's fall through for revalidation
|
|
2643
|
+
} else {
|
|
2644
|
+
if (isRedirectResult(actionResult)) {
|
|
2645
|
+
fetchControllers.delete(key);
|
|
2646
|
+
if (pendingNavigationLoadId > originatingLoadId) {
|
|
2647
|
+
// A new navigation was kicked off after our action started, so that
|
|
2648
|
+
// should take precedence over this redirect navigation. We already
|
|
2649
|
+
// set isRevalidationRequired so all loaders for the new route should
|
|
2650
|
+
// fire unless opted out via shouldRevalidate
|
|
2651
|
+
updateFetcherState(key, getDoneFetcher(undefined));
|
|
2652
|
+
return;
|
|
2653
|
+
} else {
|
|
2654
|
+
fetchRedirectIds.add(key);
|
|
2655
|
+
updateFetcherState(key, getLoadingFetcher(submission));
|
|
2656
|
+
return startRedirectNavigation(state, actionResult, {
|
|
2657
|
+
fetcherSubmission: submission
|
|
2658
|
+
});
|
|
2659
|
+
}
|
|
2660
|
+
}
|
|
2652
2661
|
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2662
|
+
// Process any non-redirect errors thrown
|
|
2663
|
+
if (isErrorResult(actionResult)) {
|
|
2664
|
+
setFetcherError(key, routeId, actionResult.error);
|
|
2665
|
+
return;
|
|
2666
|
+
}
|
|
2657
2667
|
}
|
|
2658
2668
|
if (isDeferredResult(actionResult)) {
|
|
2659
2669
|
throw getInternalRouterError(400, {
|
|
@@ -2772,7 +2782,7 @@
|
|
|
2772
2782
|
let fetchRequest = createClientSideRequest(init.history, path, abortController.signal);
|
|
2773
2783
|
fetchControllers.set(key, abortController);
|
|
2774
2784
|
let originatingLoadId = incrementingLoadId;
|
|
2775
|
-
let result = await callLoaderOrAction("loader", fetchRequest, match, matches, manifest, mapRouteProperties, basename);
|
|
2785
|
+
let result = await callLoaderOrAction("loader", fetchRequest, match, matches, manifest, mapRouteProperties, basename, future.v7_relativeSplatPath);
|
|
2776
2786
|
|
|
2777
2787
|
// Deferred isn't supported for fetcher loads, await everything and treat it
|
|
2778
2788
|
// as a normal load. resolveDeferredData will return undefined if this
|
|
@@ -2790,6 +2800,9 @@
|
|
|
2790
2800
|
if (fetchRequest.signal.aborted) {
|
|
2791
2801
|
return;
|
|
2792
2802
|
}
|
|
2803
|
+
|
|
2804
|
+
// We don't want errors bubbling up or redirects followed for unmounted
|
|
2805
|
+
// fetchers, so short circuit here if it was removed from the UI
|
|
2793
2806
|
if (deletedFetchers.has(key)) {
|
|
2794
2807
|
updateFetcherState(key, getDoneFetcher(undefined));
|
|
2795
2808
|
return;
|
|
@@ -2920,9 +2933,9 @@
|
|
|
2920
2933
|
// Call all navigation loaders and revalidating fetcher loaders in parallel,
|
|
2921
2934
|
// then slice off the results into separate arrays so we can handle them
|
|
2922
2935
|
// accordingly
|
|
2923
|
-
let results = await Promise.all([...matchesToLoad.map(match => callLoaderOrAction("loader", request, match, matches, manifest, mapRouteProperties, basename)), ...fetchersToLoad.map(f => {
|
|
2936
|
+
let results = await Promise.all([...matchesToLoad.map(match => callLoaderOrAction("loader", request, match, matches, manifest, mapRouteProperties, basename, future.v7_relativeSplatPath)), ...fetchersToLoad.map(f => {
|
|
2924
2937
|
if (f.matches && f.match && f.controller) {
|
|
2925
|
-
return callLoaderOrAction("loader", createClientSideRequest(init.history, f.path, f.controller.signal), f.match, f.matches, manifest, mapRouteProperties, basename);
|
|
2938
|
+
return callLoaderOrAction("loader", createClientSideRequest(init.history, f.path, f.controller.signal), f.match, f.matches, manifest, mapRouteProperties, basename, future.v7_relativeSplatPath);
|
|
2926
2939
|
} else {
|
|
2927
2940
|
let error = {
|
|
2928
2941
|
type: ResultType.error,
|
|
@@ -3241,6 +3254,11 @@
|
|
|
3241
3254
|
////////////////////////////////////////////////////////////////////////////////
|
|
3242
3255
|
|
|
3243
3256
|
const UNSAFE_DEFERRED_SYMBOL = Symbol("deferred");
|
|
3257
|
+
|
|
3258
|
+
/**
|
|
3259
|
+
* Future flags to toggle new feature behavior
|
|
3260
|
+
*/
|
|
3261
|
+
|
|
3244
3262
|
function createStaticHandler(routes, opts) {
|
|
3245
3263
|
invariant(routes.length > 0, "You must provide a non-empty routes array to createStaticHandler");
|
|
3246
3264
|
let manifest = {};
|
|
@@ -3257,6 +3275,10 @@
|
|
|
3257
3275
|
} else {
|
|
3258
3276
|
mapRouteProperties = defaultMapRouteProperties;
|
|
3259
3277
|
}
|
|
3278
|
+
// Config driven behavior flags
|
|
3279
|
+
let future = _extends({
|
|
3280
|
+
v7_relativeSplatPath: false
|
|
3281
|
+
}, opts ? opts.future : null);
|
|
3260
3282
|
let dataRoutes = convertRoutesToDataRoutes(routes, mapRouteProperties, undefined, manifest);
|
|
3261
3283
|
|
|
3262
3284
|
/**
|
|
@@ -3472,7 +3494,7 @@
|
|
|
3472
3494
|
error
|
|
3473
3495
|
};
|
|
3474
3496
|
} else {
|
|
3475
|
-
result = await callLoaderOrAction("action", request, actionMatch, matches, manifest, mapRouteProperties, basename, {
|
|
3497
|
+
result = await callLoaderOrAction("action", request, actionMatch, matches, manifest, mapRouteProperties, basename, future.v7_relativeSplatPath, {
|
|
3476
3498
|
isStaticRequest: true,
|
|
3477
3499
|
isRouteRequest,
|
|
3478
3500
|
requestContext
|
|
@@ -3591,7 +3613,7 @@
|
|
|
3591
3613
|
activeDeferreds: null
|
|
3592
3614
|
};
|
|
3593
3615
|
}
|
|
3594
|
-
let results = await Promise.all([...matchesToLoad.map(match => callLoaderOrAction("loader", request, match, matches, manifest, mapRouteProperties, basename, {
|
|
3616
|
+
let results = await Promise.all([...matchesToLoad.map(match => callLoaderOrAction("loader", request, match, matches, manifest, mapRouteProperties, basename, future.v7_relativeSplatPath, {
|
|
3595
3617
|
isStaticRequest: true,
|
|
3596
3618
|
isRouteRequest,
|
|
3597
3619
|
requestContext
|
|
@@ -3646,7 +3668,7 @@
|
|
|
3646
3668
|
function isSubmissionNavigation(opts) {
|
|
3647
3669
|
return opts != null && ("formData" in opts && opts.formData != null || "body" in opts && opts.body !== undefined);
|
|
3648
3670
|
}
|
|
3649
|
-
function normalizeTo(location, matches, basename, prependBasename, to, fromRouteId, relative) {
|
|
3671
|
+
function normalizeTo(location, matches, basename, prependBasename, to, v7_relativeSplatPath, fromRouteId, relative) {
|
|
3650
3672
|
let contextualMatches;
|
|
3651
3673
|
let activeRouteMatch;
|
|
3652
3674
|
if (fromRouteId) {
|
|
@@ -3666,7 +3688,7 @@
|
|
|
3666
3688
|
}
|
|
3667
3689
|
|
|
3668
3690
|
// Resolve the relative path
|
|
3669
|
-
let path = resolveTo(to ? to : ".", getResolveToMatches(contextualMatches), stripBasename(location.pathname, basename) || location.pathname, relative === "path");
|
|
3691
|
+
let path = resolveTo(to ? to : ".", getResolveToMatches(contextualMatches, v7_relativeSplatPath), stripBasename(location.pathname, basename) || location.pathname, relative === "path");
|
|
3670
3692
|
|
|
3671
3693
|
// When `to` is not specified we inherit search/hash from the current
|
|
3672
3694
|
// location, unlike when to="." and we just inherit the path.
|
|
@@ -3839,18 +3861,24 @@
|
|
|
3839
3861
|
let boundaryId = pendingError ? Object.keys(pendingError)[0] : undefined;
|
|
3840
3862
|
let boundaryMatches = getLoaderMatchesUntilBoundary(matches, boundaryId);
|
|
3841
3863
|
let navigationMatches = boundaryMatches.filter((match, index) => {
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
}
|
|
3847
|
-
if (match.route.lazy) {
|
|
3864
|
+
let {
|
|
3865
|
+
route
|
|
3866
|
+
} = match;
|
|
3867
|
+
if (route.lazy) {
|
|
3848
3868
|
// We haven't loaded this route yet so we don't know if it's got a loader!
|
|
3849
3869
|
return true;
|
|
3850
3870
|
}
|
|
3851
|
-
if (
|
|
3871
|
+
if (route.loader == null) {
|
|
3852
3872
|
return false;
|
|
3853
3873
|
}
|
|
3874
|
+
if (isInitialLoad) {
|
|
3875
|
+
if (route.loader.hydrate) {
|
|
3876
|
+
return true;
|
|
3877
|
+
}
|
|
3878
|
+
return state.loaderData[route.id] === undefined && (
|
|
3879
|
+
// Don't re-run if the loader ran and threw an error
|
|
3880
|
+
!state.errors || state.errors[route.id] === undefined);
|
|
3881
|
+
}
|
|
3854
3882
|
|
|
3855
3883
|
// Always call the loader on new route instances and pending defer cancellations
|
|
3856
3884
|
if (isNewLoader(state.loaderData, state.matches[index], match) || cancelledDeferredRoutes.some(id => id === match.route.id)) {
|
|
@@ -3952,20 +3980,6 @@
|
|
|
3952
3980
|
});
|
|
3953
3981
|
return [navigationMatches, revalidatingFetchers];
|
|
3954
3982
|
}
|
|
3955
|
-
|
|
3956
|
-
// Is this route unhydrated (when v7_partialHydration=true) such that we need
|
|
3957
|
-
// to call it's loader on the initial router creation
|
|
3958
|
-
function isUnhydratedRoute(state, route) {
|
|
3959
|
-
if (!route.loader) {
|
|
3960
|
-
return false;
|
|
3961
|
-
}
|
|
3962
|
-
if (route.loader.hydrate) {
|
|
3963
|
-
return true;
|
|
3964
|
-
}
|
|
3965
|
-
return state.loaderData[route.id] === undefined && (!state.errors ||
|
|
3966
|
-
// Loader ran but errored - don't re-run
|
|
3967
|
-
state.errors[route.id] === undefined);
|
|
3968
|
-
}
|
|
3969
3983
|
function isNewLoader(currentLoaderData, currentMatch, match) {
|
|
3970
3984
|
let isNew =
|
|
3971
3985
|
// [a] -> [a, b]
|
|
@@ -4052,7 +4066,7 @@
|
|
|
4052
4066
|
lazy: undefined
|
|
4053
4067
|
}));
|
|
4054
4068
|
}
|
|
4055
|
-
async function callLoaderOrAction(type, request, match, matches, manifest, mapRouteProperties, basename, opts) {
|
|
4069
|
+
async function callLoaderOrAction(type, request, match, matches, manifest, mapRouteProperties, basename, v7_relativeSplatPath, opts) {
|
|
4056
4070
|
if (opts === void 0) {
|
|
4057
4071
|
opts = {};
|
|
4058
4072
|
}
|
|
@@ -4142,7 +4156,7 @@
|
|
|
4142
4156
|
|
|
4143
4157
|
// Support relative routing in internal redirects
|
|
4144
4158
|
if (!ABSOLUTE_URL_REGEX.test(location)) {
|
|
4145
|
-
location = normalizeTo(new URL(request.url), matches.slice(0, matches.indexOf(match) + 1), basename, true, location);
|
|
4159
|
+
location = normalizeTo(new URL(request.url), matches.slice(0, matches.indexOf(match) + 1), basename, true, location, v7_relativeSplatPath);
|
|
4146
4160
|
} else if (!opts.isStaticRequest) {
|
|
4147
4161
|
// Strip off the protocol+origin for same-origin + same-basename absolute
|
|
4148
4162
|
// redirects. If this is a static request, we can let it go back to the
|
|
@@ -4183,13 +4197,20 @@
|
|
|
4183
4197
|
throw queryRouteResponse;
|
|
4184
4198
|
}
|
|
4185
4199
|
let data;
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4200
|
+
try {
|
|
4201
|
+
let contentType = result.headers.get("Content-Type");
|
|
4202
|
+
// Check between word boundaries instead of startsWith() due to the last
|
|
4203
|
+
// paragraph of https://httpwg.org/specs/rfc9110.html#field.content-type
|
|
4204
|
+
if (contentType && /\bapplication\/json\b/.test(contentType)) {
|
|
4205
|
+
data = await result.json();
|
|
4206
|
+
} else {
|
|
4207
|
+
data = await result.text();
|
|
4208
|
+
}
|
|
4209
|
+
} catch (e) {
|
|
4210
|
+
return {
|
|
4211
|
+
type: ResultType.error,
|
|
4212
|
+
error: e
|
|
4213
|
+
};
|
|
4193
4214
|
}
|
|
4194
4215
|
if (resultType === ResultType.error) {
|
|
4195
4216
|
return {
|