react-router 7.18.2 → 7.18.4
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 +15 -0
- package/dist/development/{browser-DBmQ1yAR.d.mts → browser-BR5QG7ZC.d.mts} +1 -1
- package/dist/development/{browser-B2PdsXXH.d.ts → browser-eq4RgLsD.d.ts} +1 -1
- package/dist/development/{chunk-HHGH3NKS.js → chunk-GR4NQCSD.js} +122 -19
- package/dist/development/{chunk-ZA36QIGN.mjs → chunk-H4DAEOV7.mjs} +16 -8
- package/dist/development/{chunk-7XGYIT3M.js → chunk-HQO5H5CC.js} +103 -103
- package/dist/{production/chunk-VJZ67BZE.js → development/chunk-LVPI3KDG.js} +7 -7
- package/dist/development/{chunk-62JRHF6Z.mjs → chunk-OB3PAWPO.mjs} +117 -14
- package/dist/{production/context-CeD5LmaF.d.mts → development/context-nqAapj74.d.mts} +9 -0
- package/dist/development/dom-export.d.mts +2 -2
- package/dist/development/dom-export.d.ts +2 -2
- package/dist/development/dom-export.js +45 -32
- package/dist/development/dom-export.mjs +17 -4
- package/dist/{production/index-react-server-client-3ykjivgQ.d.ts → development/index-react-server-client-BjY-eKuf.d.ts} +2 -1
- package/dist/{production/index-react-server-client-CACgcj2J.d.mts → development/index-react-server-client-K63fpMH4.d.mts} +1 -1
- package/dist/development/index-react-server-client.d.mts +2 -2
- package/dist/development/index-react-server-client.d.ts +2 -2
- package/dist/development/index-react-server-client.js +4 -4
- package/dist/development/index-react-server-client.mjs +2 -2
- package/dist/development/index-react-server.d.mts +8 -0
- package/dist/development/index-react-server.d.ts +8 -0
- package/dist/development/index-react-server.js +25 -9
- package/dist/development/index-react-server.mjs +25 -9
- package/dist/development/index.d.mts +6 -6
- package/dist/development/index.d.ts +6 -6
- package/dist/development/index.js +102 -94
- package/dist/development/index.mjs +3 -3
- package/dist/{production/instrumentation-Dkmpzd13.d.ts → development/instrumentation-B7w3_Eo9.d.ts} +8 -0
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/production/{browser-DBmQ1yAR.d.mts → browser-BR5QG7ZC.d.mts} +1 -1
- package/dist/production/{browser-B2PdsXXH.d.ts → browser-eq4RgLsD.d.ts} +1 -1
- package/dist/production/{chunk-FDTIF24W.js → chunk-AOOKMWND.js} +103 -103
- package/dist/production/{chunk-SJTG3J2Q.mjs → chunk-G2MPF4YY.mjs} +16 -8
- package/dist/production/{chunk-YBLPXYCV.mjs → chunk-Q34X6AWR.mjs} +117 -14
- package/dist/{development/chunk-3UVS743K.js → production/chunk-QURBR4FZ.js} +7 -7
- package/dist/production/{chunk-TP6EHSSF.js → chunk-YNGRUB6F.js} +122 -19
- package/dist/{development/context-CeD5LmaF.d.mts → production/context-nqAapj74.d.mts} +9 -0
- package/dist/production/dom-export.d.mts +2 -2
- package/dist/production/dom-export.d.ts +2 -2
- package/dist/production/dom-export.js +45 -32
- package/dist/production/dom-export.mjs +17 -4
- package/dist/{development/index-react-server-client-3ykjivgQ.d.ts → production/index-react-server-client-BjY-eKuf.d.ts} +2 -1
- package/dist/{development/index-react-server-client-CACgcj2J.d.mts → production/index-react-server-client-K63fpMH4.d.mts} +1 -1
- package/dist/production/index-react-server-client.d.mts +2 -2
- package/dist/production/index-react-server-client.d.ts +2 -2
- package/dist/production/index-react-server-client.js +4 -4
- package/dist/production/index-react-server-client.mjs +2 -2
- package/dist/production/index-react-server.d.mts +8 -0
- package/dist/production/index-react-server.d.ts +8 -0
- package/dist/production/index-react-server.js +25 -9
- package/dist/production/index-react-server.mjs +25 -9
- package/dist/production/index.d.mts +6 -6
- package/dist/production/index.d.ts +6 -6
- package/dist/production/index.js +102 -94
- package/dist/production/index.mjs +3 -3
- package/dist/{development/instrumentation-Dkmpzd13.d.ts → production/instrumentation-B7w3_Eo9.d.ts} +8 -0
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# `react-router`
|
|
2
2
|
|
|
3
|
+
## v7.18.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Correctly escape streamed RSC redirect locations in meta tag attributes ([#15492](https://github.com/remix-run/react-router/pull/15492))
|
|
8
|
+
- Avoid unintended `document.startViewTransition` calls during initial hydration and `router.revalidate()` calls ([#15485](https://github.com/remix-run/react-router/pull/15485))
|
|
9
|
+
|
|
10
|
+
## v7.18.3
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Improve route matching performance for long paths ([#15423](https://github.com/remix-run/react-router/pull/15423))
|
|
15
|
+
- Improve validation of action request origins ([#15420](https://github.com/remix-run/react-router/pull/15420))
|
|
16
|
+
- Add additional URL validation on client side navigations/redirects ([#15446](https://github.com/remix-run/react-router/pull/15446))
|
|
17
|
+
|
|
3
18
|
## v7.18.2
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { R as RouterInit } from './context-
|
|
2
|
+
import { R as RouterInit } from './context-nqAapj74.mjs';
|
|
3
3
|
import { L as Location, C as ClientActionFunction, a as ClientLoaderFunction, b as LinksFunction, M as MetaFunction, S as ShouldRevalidateFunction, P as Params, c as RouterContextProvider, A as ActionFunction, H as HeadersFunction, d as LoaderFunction } from './data-DEjBmEfD.mjs';
|
|
4
4
|
|
|
5
5
|
declare function getRequest(): Request;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { R as RouterInit } from './instrumentation-
|
|
2
|
+
import { R as RouterInit } from './instrumentation-B7w3_Eo9.js';
|
|
3
3
|
import { L as Location, C as ClientActionFunction, a as ClientLoaderFunction, b as LinksFunction, M as MetaFunction, S as ShouldRevalidateFunction, P as Params, c as RouterContextProvider, A as ActionFunction, H as HeadersFunction, d as LoaderFunction } from './data-CjO11-hU.js';
|
|
4
4
|
|
|
5
5
|
declare function getRequest(): Request;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
|
|
2
|
-
* react-router v7.18.
|
|
2
|
+
* react-router v7.18.4
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -784,13 +784,16 @@ function matchPathImpl(pattern, pathname, matcher, compiledParams) {
|
|
|
784
784
|
let match = pathname.match(matcher);
|
|
785
785
|
if (!match) return null;
|
|
786
786
|
let matchedPathname = match[0];
|
|
787
|
-
let pathnameBase = matchedPathname
|
|
787
|
+
let pathnameBase = removeTrailingSlash(matchedPathname, 1);
|
|
788
788
|
let captureGroups = match.slice(1);
|
|
789
789
|
let params = compiledParams.reduce(
|
|
790
790
|
(memo2, { paramName, isOptional }, index) => {
|
|
791
791
|
if (paramName === "*") {
|
|
792
792
|
let splatValue = captureGroups[index] || "";
|
|
793
|
-
pathnameBase =
|
|
793
|
+
pathnameBase = removeTrailingSlash(
|
|
794
|
+
matchedPathname.slice(0, matchedPathname.length - splatValue.length),
|
|
795
|
+
1
|
|
796
|
+
);
|
|
794
797
|
}
|
|
795
798
|
const value = captureGroups[index];
|
|
796
799
|
if (isOptional && !value) {
|
|
@@ -880,7 +883,7 @@ function resolvePath(to, fromPathname = "/") {
|
|
|
880
883
|
let pathname;
|
|
881
884
|
if (toPathname) {
|
|
882
885
|
toPathname = removeDoubleSlashes(toPathname);
|
|
883
|
-
if (toPathname.startsWith("/")) {
|
|
886
|
+
if (toPathname.startsWith("/") || toPathname.startsWith("\\")) {
|
|
884
887
|
pathname = resolvePathname(toPathname.substring(1), "/");
|
|
885
888
|
} else {
|
|
886
889
|
pathname = resolvePathname(toPathname, fromPathname);
|
|
@@ -968,7 +971,13 @@ function resolveTo(toArg, routePathnames, locationPathname, isPathRelative = fal
|
|
|
968
971
|
}
|
|
969
972
|
var removeDoubleSlashes = (path) => path.replace(/[\\/]{2,}/g, "/");
|
|
970
973
|
var joinPaths = (paths) => removeDoubleSlashes(paths.join("/"));
|
|
971
|
-
|
|
974
|
+
function removeTrailingSlash(path, minLength = 0) {
|
|
975
|
+
let end = path.length;
|
|
976
|
+
while (end > minLength && path.charCodeAt(end - 1) === 47) {
|
|
977
|
+
end--;
|
|
978
|
+
}
|
|
979
|
+
return end === path.length ? path : path.slice(0, end);
|
|
980
|
+
}
|
|
972
981
|
var normalizePathname = (pathname) => removeTrailingSlash(pathname).replace(/^\/*/, "/");
|
|
973
982
|
var normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search;
|
|
974
983
|
var normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
|
|
@@ -1341,6 +1350,51 @@ function isPlainObject(thing) {
|
|
|
1341
1350
|
return proto === Object.prototype || proto === null || Object.getOwnPropertyNames(proto).sort().join("\0") === objectProtoNames;
|
|
1342
1351
|
}
|
|
1343
1352
|
|
|
1353
|
+
// lib/router/navigation.ts
|
|
1354
|
+
var DEFAULT_NAVIGATION_URL = new URL("http://localhost");
|
|
1355
|
+
function getNavigatorCurrentUrl(navigator) {
|
|
1356
|
+
if (navigator.createURL) {
|
|
1357
|
+
return navigator.createURL("/");
|
|
1358
|
+
}
|
|
1359
|
+
try {
|
|
1360
|
+
return new URL(navigator.createHref("/"), DEFAULT_NAVIGATION_URL);
|
|
1361
|
+
} catch (e2) {
|
|
1362
|
+
return DEFAULT_NAVIGATION_URL;
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
function isSameOrigin(a, b) {
|
|
1366
|
+
return a.origin === b.origin && (a.origin !== "null" || a.protocol === b.protocol && a.host === b.host);
|
|
1367
|
+
}
|
|
1368
|
+
function isExplicitUrl(destination, target) {
|
|
1369
|
+
if (destination.startsWith("//")) {
|
|
1370
|
+
return true;
|
|
1371
|
+
}
|
|
1372
|
+
let protocol = target.protocol.toLowerCase();
|
|
1373
|
+
if (!destination.toLowerCase().startsWith(protocol)) {
|
|
1374
|
+
return false;
|
|
1375
|
+
}
|
|
1376
|
+
return target.host === "" || destination.slice(protocol.length).startsWith("//");
|
|
1377
|
+
}
|
|
1378
|
+
function validateNavigationTarget(original, resolved, currentUrl, externalPolicy) {
|
|
1379
|
+
let originalUrl = null;
|
|
1380
|
+
try {
|
|
1381
|
+
originalUrl = original == null ? null : new URL(original, currentUrl);
|
|
1382
|
+
} catch (e3) {
|
|
1383
|
+
}
|
|
1384
|
+
let resolvedUrl = new URL(resolved, currentUrl);
|
|
1385
|
+
let originalIsExternal = originalUrl != null && !isSameOrigin(originalUrl, currentUrl);
|
|
1386
|
+
let resolvedIsExternal = !isSameOrigin(resolvedUrl, currentUrl);
|
|
1387
|
+
if (externalPolicy === "reject") {
|
|
1388
|
+
if (originalIsExternal || resolvedIsExternal) {
|
|
1389
|
+
throw new Error("External navigation is not allowed");
|
|
1390
|
+
}
|
|
1391
|
+
} else if (resolvedIsExternal) {
|
|
1392
|
+
if (originalUrl == null || !isExplicitUrl(original, originalUrl) || !isSameOrigin(originalUrl, resolvedUrl)) {
|
|
1393
|
+
throw new Error("External navigation is not allowed");
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1344
1398
|
// lib/router/router.ts
|
|
1345
1399
|
var validMutationMethodsArr = [
|
|
1346
1400
|
"POST",
|
|
@@ -1764,7 +1818,7 @@ function createRouter(init) {
|
|
|
1764
1818
|
init.history.replace(location, location.state);
|
|
1765
1819
|
}
|
|
1766
1820
|
let viewTransitionOpts;
|
|
1767
|
-
if (pendingAction === "POP" /* Pop */) {
|
|
1821
|
+
if (pendingAction === "POP" /* Pop */ && !isUninterruptedRevalidation && location !== state.location) {
|
|
1768
1822
|
let priorPaths = appliedViewTransitions.get(state.location.pathname);
|
|
1769
1823
|
if (priorPaths && priorPaths.has(location.pathname)) {
|
|
1770
1824
|
viewTransitionOpts = {
|
|
@@ -1852,11 +1906,21 @@ function createRouter(init) {
|
|
|
1852
1906
|
...opts.mask
|
|
1853
1907
|
};
|
|
1854
1908
|
maskPath = {
|
|
1855
|
-
pathname: "",
|
|
1856
|
-
search: "",
|
|
1857
|
-
hash: ""
|
|
1858
|
-
...partialPath
|
|
1909
|
+
pathname: _nullishCoalesce(partialPath.pathname, () => ( "")),
|
|
1910
|
+
search: _nullishCoalesce(partialPath.search, () => ( "")),
|
|
1911
|
+
hash: _nullishCoalesce(partialPath.hash, () => ( ""))
|
|
1859
1912
|
};
|
|
1913
|
+
if (PROTOCOL_RELATIVE_URL_REGEX.test(maskPath.pathname)) {
|
|
1914
|
+
throw new Error("External navigation is not allowed");
|
|
1915
|
+
} else if (maskPath.pathname.startsWith("\\")) {
|
|
1916
|
+
maskPath.pathname = maskPath.pathname.replace(/^\\+/, "/");
|
|
1917
|
+
}
|
|
1918
|
+
validateNavigationTarget(
|
|
1919
|
+
typeof opts.mask === "string" ? opts.mask : createPath(opts.mask),
|
|
1920
|
+
createPath(maskPath),
|
|
1921
|
+
init.history.createURL("/"),
|
|
1922
|
+
"reject"
|
|
1923
|
+
);
|
|
1860
1924
|
}
|
|
1861
1925
|
let currentLocation = state.location;
|
|
1862
1926
|
let nextLocation = createLocation(
|
|
@@ -1870,6 +1934,12 @@ function createRouter(init) {
|
|
|
1870
1934
|
...nextLocation,
|
|
1871
1935
|
...init.history.encodeLocation(nextLocation)
|
|
1872
1936
|
};
|
|
1937
|
+
validateNavigationTarget(
|
|
1938
|
+
to == null ? init.history.createHref(state.location) : typeof to === "string" ? to : createPath(to),
|
|
1939
|
+
init.history.createHref(nextLocation.mask || nextLocation),
|
|
1940
|
+
init.history.createURL("/"),
|
|
1941
|
+
"reject"
|
|
1942
|
+
);
|
|
1873
1943
|
let userReplace = opts && opts.replace != null ? opts.replace : void 0;
|
|
1874
1944
|
let historyAction = "PUSH" /* Push */;
|
|
1875
1945
|
if (userReplace === true) {
|
|
@@ -2880,12 +2950,20 @@ function createRouter(init) {
|
|
|
2880
2950
|
}
|
|
2881
2951
|
let location = redirect2.response.headers.get("Location");
|
|
2882
2952
|
invariant(location, "Expected a Location header on the redirect Response");
|
|
2953
|
+
let originalLocation = location;
|
|
2954
|
+
let currentUrl = new URL(request.url);
|
|
2883
2955
|
location = normalizeRedirectLocation(
|
|
2884
2956
|
location,
|
|
2885
|
-
|
|
2957
|
+
currentUrl,
|
|
2886
2958
|
basename,
|
|
2887
2959
|
init.history
|
|
2888
2960
|
);
|
|
2961
|
+
validateNavigationTarget(
|
|
2962
|
+
originalLocation,
|
|
2963
|
+
location,
|
|
2964
|
+
currentUrl,
|
|
2965
|
+
"allow-explicit"
|
|
2966
|
+
);
|
|
2889
2967
|
let redirectLocation = createLocation(state.location, location, {
|
|
2890
2968
|
_isRedirect: true
|
|
2891
2969
|
});
|
|
@@ -3404,6 +3482,7 @@ function createRouter(init) {
|
|
|
3404
3482
|
// Passthrough to history-aware createHref used by useHref so we get proper
|
|
3405
3483
|
// hash-aware URLs in DOM paths
|
|
3406
3484
|
createHref: (to) => init.history.createHref(to),
|
|
3485
|
+
createURL: (to) => init.history.createURL(to),
|
|
3407
3486
|
encodeLocation: (to) => init.history.encodeLocation(to),
|
|
3408
3487
|
getFetcher,
|
|
3409
3488
|
resetFetcher,
|
|
@@ -5244,7 +5323,7 @@ var invalidProtocols = [
|
|
|
5244
5323
|
function hasInvalidProtocol(location) {
|
|
5245
5324
|
try {
|
|
5246
5325
|
return invalidProtocols.includes(new URL(location).protocol);
|
|
5247
|
-
} catch (
|
|
5326
|
+
} catch (e4) {
|
|
5248
5327
|
return false;
|
|
5249
5328
|
}
|
|
5250
5329
|
}
|
|
@@ -6514,6 +6593,9 @@ var ESCAPE_REGEX = /[&><\u2028\u2029]/g;
|
|
|
6514
6593
|
function escapeHtml(html) {
|
|
6515
6594
|
return html.replace(ESCAPE_REGEX, (match) => ESCAPE_LOOKUP[match]);
|
|
6516
6595
|
}
|
|
6596
|
+
function escapeAttribute(value) {
|
|
6597
|
+
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
6598
|
+
}
|
|
6517
6599
|
|
|
6518
6600
|
// lib/dom/ssr/invariant.ts
|
|
6519
6601
|
function invariant2(value, message) {
|
|
@@ -7085,7 +7167,7 @@ function decodeRedirectErrorDigest(digest) {
|
|
|
7085
7167
|
if (typeof parsed === "object" && parsed && typeof parsed.status === "number" && typeof parsed.statusText === "string" && typeof parsed.location === "string" && typeof parsed.reloadDocument === "boolean" && typeof parsed.replace === "boolean") {
|
|
7086
7168
|
return parsed;
|
|
7087
7169
|
}
|
|
7088
|
-
} catch (
|
|
7170
|
+
} catch (e5) {
|
|
7089
7171
|
}
|
|
7090
7172
|
}
|
|
7091
7173
|
}
|
|
@@ -7102,7 +7184,7 @@ function decodeRouteErrorResponseDigest(digest) {
|
|
|
7102
7184
|
parsed.data
|
|
7103
7185
|
);
|
|
7104
7186
|
}
|
|
7105
|
-
} catch (
|
|
7187
|
+
} catch (e6) {
|
|
7106
7188
|
}
|
|
7107
7189
|
}
|
|
7108
7190
|
}
|
|
@@ -7195,6 +7277,12 @@ function useNavigateUnstable() {
|
|
|
7195
7277
|
if (dataRouterContext == null && basename !== "/") {
|
|
7196
7278
|
path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
|
|
7197
7279
|
}
|
|
7280
|
+
validateNavigationTarget(
|
|
7281
|
+
typeof to === "string" ? to : createPath(to),
|
|
7282
|
+
navigator.createHref(path),
|
|
7283
|
+
getNavigatorCurrentUrl(navigator),
|
|
7284
|
+
"reject"
|
|
7285
|
+
);
|
|
7198
7286
|
(!!options.replace ? navigator.replace : navigator.push)(
|
|
7199
7287
|
path,
|
|
7200
7288
|
options.state,
|
|
@@ -7436,7 +7524,7 @@ function RSCErrorHandler({
|
|
|
7436
7524
|
children,
|
|
7437
7525
|
error
|
|
7438
7526
|
}) {
|
|
7439
|
-
let { basename } = React3.useContext(NavigationContext);
|
|
7527
|
+
let { basename, navigator } = React3.useContext(NavigationContext);
|
|
7440
7528
|
if (typeof error === "object" && error && "digest" in error && typeof error.digest === "string") {
|
|
7441
7529
|
let redirect2 = decodeRedirectErrorDigest(error.digest);
|
|
7442
7530
|
if (redirect2) {
|
|
@@ -7444,6 +7532,12 @@ function RSCErrorHandler({
|
|
|
7444
7532
|
if (existingRedirect) throw existingRedirect;
|
|
7445
7533
|
let parsed = parseToInfo(redirect2.location, basename);
|
|
7446
7534
|
let target = parsed.absoluteURL || parsed.to;
|
|
7535
|
+
validateNavigationTarget(
|
|
7536
|
+
redirect2.location,
|
|
7537
|
+
target,
|
|
7538
|
+
getNavigatorCurrentUrl(navigator),
|
|
7539
|
+
"allow-explicit"
|
|
7540
|
+
);
|
|
7447
7541
|
if (hasInvalidProtocol(target)) {
|
|
7448
7542
|
throw new Error("Invalid redirect location");
|
|
7449
7543
|
}
|
|
@@ -8685,7 +8779,7 @@ async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, ro
|
|
|
8685
8779
|
return;
|
|
8686
8780
|
}
|
|
8687
8781
|
sessionStorage.setItem(MANIFEST_VERSION_STORAGE_KEY, manifest.version);
|
|
8688
|
-
} catch (
|
|
8782
|
+
} catch (e7) {
|
|
8689
8783
|
}
|
|
8690
8784
|
window.location.href = errorReloadPath;
|
|
8691
8785
|
console.warn("Detected manifest version mismatch, reloading...");
|
|
@@ -8696,7 +8790,7 @@ async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, ro
|
|
|
8696
8790
|
}
|
|
8697
8791
|
try {
|
|
8698
8792
|
sessionStorage.removeItem(MANIFEST_VERSION_STORAGE_KEY);
|
|
8699
|
-
} catch (
|
|
8793
|
+
} catch (e8) {
|
|
8700
8794
|
}
|
|
8701
8795
|
serverPatches = await res.json();
|
|
8702
8796
|
} catch (e) {
|
|
@@ -9730,6 +9824,7 @@ function RouterProvider({
|
|
|
9730
9824
|
let navigator = React9.useMemo(() => {
|
|
9731
9825
|
return {
|
|
9732
9826
|
createHref: router.createHref,
|
|
9827
|
+
createURL: router.createURL,
|
|
9733
9828
|
encodeLocation: router.encodeLocation,
|
|
9734
9829
|
go: (n) => router.navigate(n),
|
|
9735
9830
|
push: (to, state2, opts) => router.navigate(to, {
|
|
@@ -9862,7 +9957,7 @@ function Navigate({
|
|
|
9862
9957
|
// the router loaded. We can help them understand how to avoid that.
|
|
9863
9958
|
`<Navigate> may be used only in the context of a <Router> component.`
|
|
9864
9959
|
);
|
|
9865
|
-
let { static: isStatic } = React9.useContext(NavigationContext);
|
|
9960
|
+
let { static: isStatic, navigator } = React9.useContext(NavigationContext);
|
|
9866
9961
|
warning(
|
|
9867
9962
|
!isStatic,
|
|
9868
9963
|
`<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.`
|
|
@@ -9876,6 +9971,12 @@ function Navigate({
|
|
|
9876
9971
|
locationPathname,
|
|
9877
9972
|
relative === "path"
|
|
9878
9973
|
);
|
|
9974
|
+
validateNavigationTarget(
|
|
9975
|
+
typeof to === "string" ? to : createPath(to),
|
|
9976
|
+
navigator.createHref(path),
|
|
9977
|
+
getNavigatorCurrentUrl(navigator),
|
|
9978
|
+
"reject"
|
|
9979
|
+
);
|
|
9879
9980
|
let jsonPath = JSON.stringify(path);
|
|
9880
9981
|
React9.useEffect(() => {
|
|
9881
9982
|
navigate(JSON.parse(jsonPath), { replace: replace2, state, relative });
|
|
@@ -10304,4 +10405,6 @@ function withErrorBoundaryProps(ErrorBoundary) {
|
|
|
10304
10405
|
|
|
10305
10406
|
|
|
10306
10407
|
|
|
10307
|
-
|
|
10408
|
+
|
|
10409
|
+
|
|
10410
|
+
exports.ABSOLUTE_URL_REGEX = ABSOLUTE_URL_REGEX; exports.PROTOCOL_RELATIVE_URL_REGEX = PROTOCOL_RELATIVE_URL_REGEX; exports.Action = Action; exports.createMemoryHistory = createMemoryHistory; exports.createBrowserHistory = createBrowserHistory; exports.createHashHistory = createHashHistory; exports.invariant = invariant; exports.warning = warning; exports.createPath = createPath; exports.parsePath = parsePath; exports.createContext = createContext; exports.RouterContextProvider = RouterContextProvider; exports.convertRoutesToDataRoutes = convertRoutesToDataRoutes; exports.matchRoutes = matchRoutes; exports.matchRoutesImpl = matchRoutesImpl; exports.generatePath = generatePath; exports.matchPath = matchPath; exports.stripBasename = stripBasename; exports.resolvePath = resolvePath; exports.resolveTo = resolveTo; exports.joinPaths = joinPaths; exports.data = data; exports.redirect = redirect; exports.redirectDocument = redirectDocument; exports.replace = replace; exports.SUPPORTED_ERROR_TYPES = SUPPORTED_ERROR_TYPES; exports.ErrorResponseImpl = ErrorResponseImpl; exports.isRouteErrorResponse = isRouteErrorResponse; exports.parseToInfo = parseToInfo; exports.escapeHtml = escapeHtml; exports.escapeAttribute = escapeAttribute; exports.encode = encode; exports.instrumentHandler = instrumentHandler; exports.validateNavigationTarget = validateNavigationTarget; exports.IDLE_NAVIGATION = IDLE_NAVIGATION; exports.IDLE_FETCHER = IDLE_FETCHER; exports.IDLE_BLOCKER = IDLE_BLOCKER; exports.createRouter = createRouter; exports.createStaticHandler = createStaticHandler; exports.getStaticContextFromError = getStaticContextFromError; exports.hasInvalidProtocol = hasInvalidProtocol; exports.isDataWithResponseInit = isDataWithResponseInit; exports.isResponse = isResponse; exports.isRedirectStatusCode = isRedirectStatusCode; exports.isRedirectResponse = isRedirectResponse; exports.isMutationMethod = isMutationMethod; exports.createRequestInit = createRequestInit; exports.SingleFetchRedirectSymbol = SingleFetchRedirectSymbol; exports.SINGLE_FETCH_REDIRECT_STATUS = SINGLE_FETCH_REDIRECT_STATUS; exports.NO_BODY_STATUS_CODES = NO_BODY_STATUS_CODES; exports.StreamTransfer = StreamTransfer; exports.getTurboStreamSingleFetchDataStrategy = getTurboStreamSingleFetchDataStrategy; exports.getSingleFetchDataStrategyImpl = getSingleFetchDataStrategyImpl; exports.stripIndexParam = stripIndexParam; exports.singleFetchUrl = singleFetchUrl; exports.decodeViaTurboStream = decodeViaTurboStream; exports.DataRouterContext = DataRouterContext; exports.DataRouterStateContext = DataRouterStateContext; exports.RSCRouterContext = RSCRouterContext; exports.ViewTransitionContext = ViewTransitionContext; exports.FetchersContext = FetchersContext; exports.AwaitContextProvider = AwaitContextProvider; exports.NavigationContext = NavigationContext; exports.LocationContext = LocationContext; exports.RouteContext = RouteContext; exports.ENABLE_DEV_WARNINGS = ENABLE_DEV_WARNINGS; exports.warnOnce = warnOnce; exports.decodeRedirectErrorDigest = decodeRedirectErrorDigest; exports.decodeRouteErrorResponseDigest = decodeRouteErrorResponseDigest; exports.useHref = useHref; exports.useInRouterContext = useInRouterContext; exports.useLocation = useLocation; exports.useNavigationType = useNavigationType; exports.useMatch = useMatch; exports.useNavigate = useNavigate; exports.useOutletContext = useOutletContext; exports.useOutlet = useOutlet; exports.useParams = useParams; exports.useResolvedPath = useResolvedPath; exports.useRoutes = useRoutes; exports.useRouteId = useRouteId; exports.useNavigation = useNavigation; exports.useRevalidator = useRevalidator; exports.useMatches = useMatches; exports.useLoaderData = useLoaderData; exports.useRouteLoaderData = useRouteLoaderData; exports.useActionData = useActionData; exports.useRouteError = useRouteError; exports.useAsyncValue = useAsyncValue; exports.useAsyncError = useAsyncError; exports.useBlocker = useBlocker; exports.useRoute = useRoute; exports.useRouterState = useRouterState; exports.RemixErrorBoundary = RemixErrorBoundary; exports.createServerRoutes = createServerRoutes; exports.createClientRoutesWithHMRRevalidationOptOut = createClientRoutesWithHMRRevalidationOptOut; exports.noActionDefinedError = noActionDefinedError; exports.createClientRoutes = createClientRoutes; exports.shouldHydrateRouteLoader = shouldHydrateRouteLoader; exports.URL_LIMIT = URL_LIMIT; exports.getPathsWithAncestors = getPathsWithAncestors; exports.getPatchRoutesOnNavigationFunction = getPatchRoutesOnNavigationFunction; exports.useFogOFWarDiscovery = useFogOFWarDiscovery; exports.getManifestPath = getManifestPath; exports.FrameworkContext = FrameworkContext; exports.usePrefetchBehavior = usePrefetchBehavior; exports.CRITICAL_CSS_DATA_ATTRIBUTE = CRITICAL_CSS_DATA_ATTRIBUTE; exports.Links = Links; exports.PrefetchPageLinks = PrefetchPageLinks; exports.Meta = Meta; exports.setIsHydrated = setIsHydrated; exports.Scripts = Scripts; exports.mergeRefs = mergeRefs; exports.mapRouteProperties = mapRouteProperties; exports.hydrationRouteProperties = hydrationRouteProperties; exports.createMemoryRouter = createMemoryRouter; exports.RouterProvider = RouterProvider; exports.DataRoutes = DataRoutes2; exports.MemoryRouter = MemoryRouter; exports.Navigate = Navigate; exports.Outlet = Outlet; exports.Route = Route; exports.Router = Router; exports.Routes = Routes; exports.Await = Await; exports.createRoutesFromChildren = createRoutesFromChildren; exports.createRoutesFromElements = createRoutesFromElements; exports.renderMatches = renderMatches; exports.WithComponentProps = WithComponentProps; exports.withComponentProps = withComponentProps; exports.WithHydrateFallbackProps = WithHydrateFallbackProps; exports.withHydrateFallbackProps = withHydrateFallbackProps; exports.WithErrorBoundaryProps = WithErrorBoundaryProps; exports.withErrorBoundaryProps = withErrorBoundaryProps;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v7.18.
|
|
2
|
+
* react-router v7.18.4
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
decodeRouteErrorResponseDigest,
|
|
33
33
|
decodeViaTurboStream,
|
|
34
34
|
encode,
|
|
35
|
+
escapeAttribute,
|
|
35
36
|
escapeHtml,
|
|
36
37
|
getManifestPath,
|
|
37
38
|
getStaticContextFromError,
|
|
@@ -55,7 +56,7 @@ import {
|
|
|
55
56
|
withComponentProps,
|
|
56
57
|
withErrorBoundaryProps,
|
|
57
58
|
withHydrateFallbackProps
|
|
58
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-OB3PAWPO.mjs";
|
|
59
60
|
|
|
60
61
|
// lib/dom/ssr/server.tsx
|
|
61
62
|
import * as React from "react";
|
|
@@ -747,18 +748,25 @@ function prependCookies(parentHeaders, childHeaders) {
|
|
|
747
748
|
function throwIfPotentialCSRFAttack(request, allowedActionOrigins) {
|
|
748
749
|
let originHeader = request.headers.get("origin");
|
|
749
750
|
let originDomain = null;
|
|
751
|
+
let originUrl = null;
|
|
750
752
|
try {
|
|
751
|
-
|
|
753
|
+
if (typeof originHeader === "string" && originHeader !== "null") {
|
|
754
|
+
originUrl = new URL(originHeader);
|
|
755
|
+
originDomain = originUrl.host;
|
|
756
|
+
} else {
|
|
757
|
+
originDomain = originHeader;
|
|
758
|
+
}
|
|
752
759
|
} catch {
|
|
753
760
|
throw new Error(
|
|
754
761
|
`\`origin\` header is not a valid URL. Aborting the action.`
|
|
755
762
|
);
|
|
756
763
|
}
|
|
757
|
-
let
|
|
758
|
-
|
|
764
|
+
let requestUrl = new URL(request.url);
|
|
765
|
+
let originMatchesRequest = originUrl ? originUrl.origin === requestUrl.origin : originDomain === requestUrl.host;
|
|
766
|
+
if (originDomain && !originMatchesRequest) {
|
|
759
767
|
if (!isAllowedOrigin(originDomain, allowedActionOrigins)) {
|
|
760
768
|
throw new Error(
|
|
761
|
-
"The `request.url`
|
|
769
|
+
"The `request.url` origin does not match `origin` header from a forwarded action request. Aborting the action."
|
|
762
770
|
);
|
|
763
771
|
}
|
|
764
772
|
}
|
|
@@ -2190,7 +2198,7 @@ async function routeRSCServerRequest({
|
|
|
2190
2198
|
}
|
|
2191
2199
|
controller.enqueue(
|
|
2192
2200
|
new TextEncoder().encode(
|
|
2193
|
-
`<meta http-equiv="refresh" content="0;url=${
|
|
2201
|
+
`<meta http-equiv="refresh" content="0;url=${escapeAttribute(renderRedirect.location)}"/>`
|
|
2194
2202
|
)
|
|
2195
2203
|
);
|
|
2196
2204
|
}
|
|
@@ -2310,7 +2318,7 @@ async function routeRSCServerRequest({
|
|
|
2310
2318
|
}
|
|
2311
2319
|
controller.enqueue(
|
|
2312
2320
|
new TextEncoder().encode(
|
|
2313
|
-
`<meta http-equiv="refresh" content="0;url=${
|
|
2321
|
+
`<meta http-equiv="refresh" content="0;url=${escapeAttribute(retryRedirect.location)}"/>`
|
|
2314
2322
|
)
|
|
2315
2323
|
);
|
|
2316
2324
|
}
|