react-router 7.18.5 → 7.18.7

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.
Files changed (68) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/development/{browser-7x6a6gQP.d.ts → browser-QWJf_b8Q.d.ts} +2 -2
  3. package/dist/development/{browser-CiGxXXOl.d.mts → browser-yuOIt-hO.d.mts} +2 -2
  4. package/dist/development/{chunk-NDF5KBLP.js → chunk-6VUODQWR.js} +109 -104
  5. package/dist/development/{chunk-2ZBLYC7V.js → chunk-EYW3HBBI.js} +116 -66
  6. package/dist/development/{chunk-IFHLIXZW.js → chunk-FLL7MJ4N.js} +7 -7
  7. package/dist/development/{chunk-JAHXRPFV.mjs → chunk-IXMWVLYF.mjs} +14 -5
  8. package/dist/development/{chunk-6KYCQHYJ.mjs → chunk-Z7SQORRT.mjs} +118 -64
  9. package/dist/{production/context-BlYKn1tE.d.mts → development/context-BbKau8k8.d.mts} +1 -1
  10. package/dist/development/{data-DEjBmEfD.d.mts → data-BfpvlkTw.d.mts} +2 -0
  11. package/dist/{production/data-CjO11-hU.d.ts → development/data-DNyB6ouY.d.ts} +2 -0
  12. package/dist/development/dom-export.d.mts +3 -3
  13. package/dist/development/dom-export.d.ts +3 -3
  14. package/dist/development/dom-export.js +38 -36
  15. package/dist/development/dom-export.mjs +7 -5
  16. package/dist/development/{index-react-server-client-KK-TR-t7.d.mts → index-react-server-client-DF1LPF_n.d.mts} +2 -2
  17. package/dist/{production/index-react-server-client-BaaZU3sM.d.ts → development/index-react-server-client-DxC4rwQS.d.ts} +2 -2
  18. package/dist/development/index-react-server-client.d.mts +3 -3
  19. package/dist/development/index-react-server-client.d.ts +3 -3
  20. package/dist/development/index-react-server-client.js +4 -4
  21. package/dist/development/index-react-server-client.mjs +2 -2
  22. package/dist/development/index-react-server.js +130 -59
  23. package/dist/development/index-react-server.mjs +130 -59
  24. package/dist/development/index.d.mts +11 -11
  25. package/dist/development/index.d.ts +11 -11
  26. package/dist/development/index.js +111 -102
  27. package/dist/development/index.mjs +3 -3
  28. package/dist/{production/instrumentation-CPkMwccd.d.ts → development/instrumentation-z0GQ7yJ2.d.ts} +1 -1
  29. package/dist/development/lib/types/internal.d.mts +2 -2
  30. package/dist/development/lib/types/internal.d.ts +2 -2
  31. package/dist/development/lib/types/internal.js +1 -1
  32. package/dist/development/lib/types/internal.mjs +1 -1
  33. package/dist/development/{register-CmkRspdl.d.mts → register-B8pHflrz.d.mts} +1 -1
  34. package/dist/development/{register-roq_0qYo.d.ts → register-Dnr_kGGI.d.ts} +1 -1
  35. package/dist/production/{browser-7x6a6gQP.d.ts → browser-QWJf_b8Q.d.ts} +2 -2
  36. package/dist/production/{browser-CiGxXXOl.d.mts → browser-yuOIt-hO.d.mts} +2 -2
  37. package/dist/production/{chunk-75HN637G.js → chunk-6AFDAMLF.js} +109 -104
  38. package/dist/production/{chunk-IAM5GYT3.mjs → chunk-D2GT6IUW.mjs} +14 -5
  39. package/dist/production/{chunk-HNBICOIU.js → chunk-JAAIXHP6.js} +116 -66
  40. package/dist/production/{chunk-7RTFRKQW.mjs → chunk-OCNYVWSN.mjs} +118 -64
  41. package/dist/production/{chunk-K3NA4NUH.js → chunk-RFC7P4DG.js} +7 -7
  42. package/dist/{development/context-BlYKn1tE.d.mts → production/context-BbKau8k8.d.mts} +1 -1
  43. package/dist/production/{data-DEjBmEfD.d.mts → data-BfpvlkTw.d.mts} +2 -0
  44. package/dist/{development/data-CjO11-hU.d.ts → production/data-DNyB6ouY.d.ts} +2 -0
  45. package/dist/production/dom-export.d.mts +3 -3
  46. package/dist/production/dom-export.d.ts +3 -3
  47. package/dist/production/dom-export.js +38 -36
  48. package/dist/production/dom-export.mjs +7 -5
  49. package/dist/production/{index-react-server-client-KK-TR-t7.d.mts → index-react-server-client-DF1LPF_n.d.mts} +2 -2
  50. package/dist/{development/index-react-server-client-BaaZU3sM.d.ts → production/index-react-server-client-DxC4rwQS.d.ts} +2 -2
  51. package/dist/production/index-react-server-client.d.mts +3 -3
  52. package/dist/production/index-react-server-client.d.ts +3 -3
  53. package/dist/production/index-react-server-client.js +4 -4
  54. package/dist/production/index-react-server-client.mjs +2 -2
  55. package/dist/production/index-react-server.js +130 -59
  56. package/dist/production/index-react-server.mjs +130 -59
  57. package/dist/production/index.d.mts +11 -11
  58. package/dist/production/index.d.ts +11 -11
  59. package/dist/production/index.js +111 -102
  60. package/dist/production/index.mjs +3 -3
  61. package/dist/{development/instrumentation-CPkMwccd.d.ts → production/instrumentation-z0GQ7yJ2.d.ts} +1 -1
  62. package/dist/production/lib/types/internal.d.mts +2 -2
  63. package/dist/production/lib/types/internal.d.ts +2 -2
  64. package/dist/production/lib/types/internal.js +1 -1
  65. package/dist/production/lib/types/internal.mjs +1 -1
  66. package/dist/production/{register-CmkRspdl.d.mts → register-B8pHflrz.d.mts} +1 -1
  67. package/dist/production/{register-roq_0qYo.d.ts → register-Dnr_kGGI.d.ts} +1 -1
  68. package/package.json +5 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.18.5
2
+ * react-router v7.18.7
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -13,7 +13,7 @@ import {
13
13
  RSCRouterGlobalErrorBoundary,
14
14
  getHydrationData,
15
15
  populateRSCRouteModules
16
- } from "./chunk-JAHXRPFV.mjs";
16
+ } from "./chunk-IXMWVLYF.mjs";
17
17
  import {
18
18
  CRITICAL_CSS_DATA_ATTRIBUTE,
19
19
  ErrorResponseImpl,
@@ -47,7 +47,7 @@ import {
47
47
  stripIndexParam,
48
48
  useFogOFWarDiscovery,
49
49
  validateNavigationTarget
50
- } from "./chunk-6KYCQHYJ.mjs";
50
+ } from "./chunk-Z7SQORRT.mjs";
51
51
 
52
52
  // lib/dom-export/dom-router-provider.tsx
53
53
  import * as React from "react";
@@ -201,7 +201,9 @@ function HydratedRouter(props) {
201
201
  );
202
202
  React2.useEffect(() => {
203
203
  if (process.env.NODE_ENV === "development") {
204
- setCriticalCss(void 0);
204
+ React2.startTransition(() => {
205
+ setCriticalCss(void 0);
206
+ });
205
207
  }
206
208
  }, []);
207
209
  React2.useEffect(() => {
@@ -917,7 +919,6 @@ async function fetchAndApplyManifestPatches(paths, createFromReadableStream, fet
917
919
  if (payload.type !== "manifest") {
918
920
  throw new Error("Failed to patch routes");
919
921
  }
920
- paths.forEach((p) => addToFifoQueue(p, discoveredPaths));
921
922
  let patches = await payload.patches;
922
923
  React3.startTransition(() => {
923
924
  patches.forEach((p) => {
@@ -927,6 +928,7 @@ async function fetchAndApplyManifestPatches(paths, createFromReadableStream, fet
927
928
  );
928
929
  });
929
930
  });
931
+ paths.forEach((p) => addToFifoQueue(p, discoveredPaths));
930
932
  }
931
933
  function addToFifoQueue(path, queue) {
932
934
  if (queue.size >= discoveredPathsMaxSize) {
@@ -1,6 +1,6 @@
1
- import { o as ServerInstrumentation, H as HydrationState, h as StaticHandlerContext, f as RelativeRoutingType, g as GetScrollRestorationKeyFunction, R as RouterInit, ah as FutureConfig$1, C as ClientInstrumentation, N as NavigateOptions, F as Fetcher, c as Router, B as BlockerFunction, ai as CreateStaticHandlerOptions$1, S as StaticHandler } from './context-BlYKn1tE.mjs';
1
+ import { o as ServerInstrumentation, H as HydrationState, h as StaticHandlerContext, f as RelativeRoutingType, g as GetScrollRestorationKeyFunction, R as RouterInit, ah as FutureConfig$1, C as ClientInstrumentation, N as NavigateOptions, F as Fetcher, c as Router, B as BlockerFunction, ai as CreateStaticHandlerOptions$1, S as StaticHandler } from './context-BbKau8k8.mjs';
2
2
  import * as React from 'react';
3
- import { J as RouteManifest, aF as ServerRouteModule, p as MiddlewareEnabled, c as RouterContextProvider, q as AppLoadContext, o as LoaderFunctionArgs, a3 as ActionFunctionArgs, Z as RouteModules, E as DataRouteObject, a as ClientLoaderFunction, I as RouteBranch, m as HTMLFormMethod, n as FormEncType, aw as PageLinkDescriptor, T as To, s as History, z as DataStrategyFunction, B as PatchRoutesOnNavigationFunction, r as RouteObject, _ as SerializeFrom, L as Location } from './data-DEjBmEfD.mjs';
3
+ import { J as RouteManifest, aF as ServerRouteModule, p as MiddlewareEnabled, c as RouterContextProvider, q as AppLoadContext, o as LoaderFunctionArgs, a3 as ActionFunctionArgs, Z as RouteModules, E as DataRouteObject, a as ClientLoaderFunction, I as RouteBranch, m as HTMLFormMethod, n as FormEncType, aw as PageLinkDescriptor, T as To, s as History, z as DataStrategyFunction, B as PatchRoutesOnNavigationFunction, r as RouteObject, _ as SerializeFrom, L as Location } from './data-BfpvlkTw.mjs';
4
4
 
5
5
  type ServerRouteManifest = RouteManifest<Omit<ServerRoute, "children">>;
6
6
  interface ServerRoute extends Route {
@@ -1,6 +1,6 @@
1
- import { l as ServerInstrumentation, H as HydrationState, e as StaticHandlerContext, c as RelativeRoutingType, a as Router$1, g as RouterState, R as RouterInit, t as FutureConfig$1, C as ClientInstrumentation, d as GetScrollRestorationKeyFunction, F as Fetcher, B as BlockerFunction, u as CreateStaticHandlerOptions$1, S as StaticHandler } from './instrumentation-CPkMwccd.js';
1
+ import { l as ServerInstrumentation, H as HydrationState, e as StaticHandlerContext, c as RelativeRoutingType, a as Router$1, g as RouterState, R as RouterInit, t as FutureConfig$1, C as ClientInstrumentation, d as GetScrollRestorationKeyFunction, F as Fetcher, B as BlockerFunction, u as CreateStaticHandlerOptions$1, S as StaticHandler } from './instrumentation-z0GQ7yJ2.js';
2
2
  import * as React from 'react';
3
- import { p as RouteManifest, aE as ServerRouteModule, t as MiddlewareEnabled, c as RouterContextProvider, u as AppLoadContext, s as LoaderFunctionArgs, a0 as ActionFunctionArgs, O as RouteModules, n as DataRouteObject, a as ClientLoaderFunction, o as RouteBranch, aF as TrackedPromise, f as History, T as To, L as Location, i as Action, ac as RouteMatch, Y as InitialEntry, _ as NonIndexRouteObject, a7 as LazyRouteFunction, Z as IndexRouteObject, P as Params, l as DataStrategyFunction, m as PatchRoutesOnNavigationFunction, e as RouteObject, U as UIMatch, q as HTMLFormMethod, F as FormEncType, av as PageLinkDescriptor, Q as SerializeFrom } from './data-CjO11-hU.js';
3
+ import { p as RouteManifest, aE as ServerRouteModule, t as MiddlewareEnabled, c as RouterContextProvider, u as AppLoadContext, s as LoaderFunctionArgs, a0 as ActionFunctionArgs, O as RouteModules, n as DataRouteObject, a as ClientLoaderFunction, o as RouteBranch, aF as TrackedPromise, f as History, T as To, L as Location, i as Action, ac as RouteMatch, Y as InitialEntry, _ as NonIndexRouteObject, a7 as LazyRouteFunction, Z as IndexRouteObject, P as Params, l as DataStrategyFunction, m as PatchRoutesOnNavigationFunction, e as RouteObject, U as UIMatch, q as HTMLFormMethod, F as FormEncType, av as PageLinkDescriptor, Q as SerializeFrom } from './data-DNyB6ouY.js';
4
4
 
5
5
  type ServerRouteManifest = RouteManifest<Omit<ServerRoute, "children">>;
6
6
  interface ServerRoute extends Route$1 {
@@ -1,4 +1,4 @@
1
- export { Q as MemoryRouter, T as Navigate, U as Outlet, V as Route, W as Router, X as RouterProvider, Y as Routes, A as UNSAFE_AwaitContextProvider, ab as UNSAFE_WithComponentProps, af as UNSAFE_WithErrorBoundaryProps, ad as UNSAFE_WithHydrateFallbackProps } from './context-BlYKn1tE.mjs';
2
- export { l as BrowserRouter, q as Form, m as HashRouter, n as Link, X as Links, W as Meta, p as NavLink, r as ScrollRestoration, T as StaticRouter, V as StaticRouterProvider, o as unstable_HistoryRouter } from './index-react-server-client-KK-TR-t7.mjs';
3
- import './data-DEjBmEfD.mjs';
1
+ export { Q as MemoryRouter, T as Navigate, U as Outlet, V as Route, W as Router, X as RouterProvider, Y as Routes, A as UNSAFE_AwaitContextProvider, ab as UNSAFE_WithComponentProps, af as UNSAFE_WithErrorBoundaryProps, ad as UNSAFE_WithHydrateFallbackProps } from './context-BbKau8k8.mjs';
2
+ export { l as BrowserRouter, q as Form, m as HashRouter, n as Link, X as Links, W as Meta, p as NavLink, r as ScrollRestoration, T as StaticRouter, V as StaticRouterProvider, o as unstable_HistoryRouter } from './index-react-server-client-DF1LPF_n.mjs';
3
+ import './data-BfpvlkTw.mjs';
4
4
  import 'react';
@@ -1,4 +1,4 @@
1
- export { W as BrowserRouter, $ as Form, X as HashRouter, Y as Link, an as Links, j as MemoryRouter, am as Meta, _ as NavLink, k as Navigate, l as Outlet, m as Route, n as Router, o as RouterProvider, p as Routes, a0 as ScrollRestoration, ak as StaticRouter, al as StaticRouterProvider, b as UNSAFE_AwaitContextProvider, aH as UNSAFE_WithComponentProps, aL as UNSAFE_WithErrorBoundaryProps, aJ as UNSAFE_WithHydrateFallbackProps, Z as unstable_HistoryRouter } from './index-react-server-client-BaaZU3sM.js';
2
- import './instrumentation-CPkMwccd.js';
3
- import './data-CjO11-hU.js';
1
+ export { W as BrowserRouter, $ as Form, X as HashRouter, Y as Link, an as Links, j as MemoryRouter, am as Meta, _ as NavLink, k as Navigate, l as Outlet, m as Route, n as Router, o as RouterProvider, p as Routes, a0 as ScrollRestoration, ak as StaticRouter, al as StaticRouterProvider, b as UNSAFE_AwaitContextProvider, aH as UNSAFE_WithComponentProps, aL as UNSAFE_WithErrorBoundaryProps, aJ as UNSAFE_WithHydrateFallbackProps, Z as unstable_HistoryRouter } from './index-react-server-client-DxC4rwQS.js';
2
+ import './instrumentation-z0GQ7yJ2.js';
3
+ import './data-DNyB6ouY.js';
4
4
  import 'react';
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});/**
2
- * react-router v7.18.5
2
+ * react-router v7.18.7
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -19,7 +19,7 @@
19
19
 
20
20
 
21
21
 
22
- var _chunkNDF5KBLPjs = require('./chunk-NDF5KBLP.js');
22
+ var _chunk6VUODQWRjs = require('./chunk-6VUODQWR.js');
23
23
 
24
24
 
25
25
 
@@ -34,7 +34,7 @@ var _chunkNDF5KBLPjs = require('./chunk-NDF5KBLP.js');
34
34
 
35
35
 
36
36
 
37
- var _chunk2ZBLYC7Vjs = require('./chunk-2ZBLYC7V.js');
37
+ var _chunkEYW3HBBIjs = require('./chunk-EYW3HBBI.js');
38
38
 
39
39
 
40
40
 
@@ -58,4 +58,4 @@ var _chunk2ZBLYC7Vjs = require('./chunk-2ZBLYC7V.js');
58
58
 
59
59
 
60
60
 
61
- exports.BrowserRouter = _chunkNDF5KBLPjs.BrowserRouter; exports.Form = _chunkNDF5KBLPjs.Form; exports.HashRouter = _chunkNDF5KBLPjs.HashRouter; exports.Link = _chunkNDF5KBLPjs.Link; exports.Links = _chunk2ZBLYC7Vjs.Links; exports.MemoryRouter = _chunk2ZBLYC7Vjs.MemoryRouter; exports.Meta = _chunk2ZBLYC7Vjs.Meta; exports.NavLink = _chunkNDF5KBLPjs.NavLink; exports.Navigate = _chunk2ZBLYC7Vjs.Navigate; exports.Outlet = _chunk2ZBLYC7Vjs.Outlet; exports.Route = _chunk2ZBLYC7Vjs.Route; exports.Router = _chunk2ZBLYC7Vjs.Router; exports.RouterProvider = _chunk2ZBLYC7Vjs.RouterProvider; exports.Routes = _chunk2ZBLYC7Vjs.Routes; exports.ScrollRestoration = _chunkNDF5KBLPjs.ScrollRestoration; exports.StaticRouter = _chunkNDF5KBLPjs.StaticRouter; exports.StaticRouterProvider = _chunkNDF5KBLPjs.StaticRouterProvider; exports.UNSAFE_AwaitContextProvider = _chunk2ZBLYC7Vjs.AwaitContextProvider; exports.UNSAFE_WithComponentProps = _chunk2ZBLYC7Vjs.WithComponentProps; exports.UNSAFE_WithErrorBoundaryProps = _chunk2ZBLYC7Vjs.WithErrorBoundaryProps; exports.UNSAFE_WithHydrateFallbackProps = _chunk2ZBLYC7Vjs.WithHydrateFallbackProps; exports.unstable_HistoryRouter = _chunkNDF5KBLPjs.HistoryRouter;
61
+ exports.BrowserRouter = _chunk6VUODQWRjs.BrowserRouter; exports.Form = _chunk6VUODQWRjs.Form; exports.HashRouter = _chunk6VUODQWRjs.HashRouter; exports.Link = _chunk6VUODQWRjs.Link; exports.Links = _chunkEYW3HBBIjs.Links; exports.MemoryRouter = _chunkEYW3HBBIjs.MemoryRouter; exports.Meta = _chunkEYW3HBBIjs.Meta; exports.NavLink = _chunk6VUODQWRjs.NavLink; exports.Navigate = _chunkEYW3HBBIjs.Navigate; exports.Outlet = _chunkEYW3HBBIjs.Outlet; exports.Route = _chunkEYW3HBBIjs.Route; exports.Router = _chunkEYW3HBBIjs.Router; exports.RouterProvider = _chunkEYW3HBBIjs.RouterProvider; exports.Routes = _chunkEYW3HBBIjs.Routes; exports.ScrollRestoration = _chunk6VUODQWRjs.ScrollRestoration; exports.StaticRouter = _chunk6VUODQWRjs.StaticRouter; exports.StaticRouterProvider = _chunk6VUODQWRjs.StaticRouterProvider; exports.UNSAFE_AwaitContextProvider = _chunkEYW3HBBIjs.AwaitContextProvider; exports.UNSAFE_WithComponentProps = _chunkEYW3HBBIjs.WithComponentProps; exports.UNSAFE_WithErrorBoundaryProps = _chunkEYW3HBBIjs.WithErrorBoundaryProps; exports.UNSAFE_WithHydrateFallbackProps = _chunkEYW3HBBIjs.WithHydrateFallbackProps; exports.unstable_HistoryRouter = _chunk6VUODQWRjs.HistoryRouter;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.18.5
2
+ * react-router v7.18.7
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -32,7 +32,7 @@ import {
32
32
  WithComponentProps,
33
33
  WithErrorBoundaryProps,
34
34
  WithHydrateFallbackProps
35
- } from "./chunk-6KYCQHYJ.mjs";
35
+ } from "./chunk-Z7SQORRT.mjs";
36
36
  export {
37
37
  BrowserRouter,
38
38
  Form,
@@ -27,7 +27,7 @@ function _interopNamespace(e) {
27
27
  var React3__namespace = /*#__PURE__*/_interopNamespace(React3);
28
28
 
29
29
  /**
30
- * react-router v7.18.5
30
+ * react-router v7.18.7
31
31
  *
32
32
  * Copyright (c) Remix Software Inc.
33
33
  *
@@ -293,6 +293,53 @@ function isPlainObject(thing) {
293
293
  return proto === Object.prototype || proto === null || Object.getOwnPropertyNames(proto).sort().join("\0") === objectProtoNames;
294
294
  }
295
295
 
296
+ // lib/router/navigation.ts
297
+ var DEFAULT_NAVIGATION_URL = new URL("http://localhost");
298
+ function isSameOrigin(a, b) {
299
+ return a.origin === b.origin && (a.origin !== "null" || a.protocol === b.protocol && a.host === b.host);
300
+ }
301
+ function isExplicitUrl(destination, target) {
302
+ if (destination.startsWith("//")) {
303
+ return true;
304
+ }
305
+ let protocol = target.protocol.toLowerCase();
306
+ if (!destination.toLowerCase().startsWith(protocol)) {
307
+ return false;
308
+ }
309
+ return target.host === "" || destination.slice(protocol.length).startsWith("//");
310
+ }
311
+ function validateDocumentNavigationTarget(destination) {
312
+ let normalized = destination.replace(/[\t\n\r]/g, "");
313
+ let start = 0;
314
+ while (normalized.charCodeAt(start) <= 32) start++;
315
+ normalized = normalized.slice(start);
316
+ if (!ABSOLUTE_URL_REGEX.test(normalized)) return;
317
+ let target;
318
+ try {
319
+ target = new URL(destination, DEFAULT_NAVIGATION_URL);
320
+ } catch {
321
+ return;
322
+ }
323
+ if (!isExplicitUrl(destination, target)) {
324
+ throw new Error("External navigation is not allowed");
325
+ }
326
+ }
327
+ function validateNavigationTarget(original, resolved, currentUrl, externalPolicy) {
328
+ let originalUrl = null;
329
+ try {
330
+ originalUrl = original == null ? null : new URL(original, currentUrl);
331
+ } catch {
332
+ }
333
+ let resolvedUrl = new URL(resolved, currentUrl);
334
+ originalUrl != null && !isSameOrigin(originalUrl, currentUrl);
335
+ let resolvedIsExternal = !isSameOrigin(resolvedUrl, currentUrl);
336
+ if (resolvedIsExternal) {
337
+ if (originalUrl == null || !isExplicitUrl(original, originalUrl) || !isSameOrigin(originalUrl, resolvedUrl)) {
338
+ throw new Error("External navigation is not allowed");
339
+ }
340
+ }
341
+ }
342
+
296
343
  // lib/router/utils.ts
297
344
  function createContext(defaultValue) {
298
345
  return { defaultValue };
@@ -649,12 +696,22 @@ function matchRouteBranch(branch, pathname, allowPartial = false) {
649
696
  }
650
697
  return matches;
651
698
  }
699
+ var MAX_OPTIONAL_PATH_SEGMENTS = 12;
652
700
  function matchPath(pattern, pathname) {
653
701
  if (typeof pattern === "string") {
654
702
  pattern = { path: pattern, caseSensitive: false, end: true };
655
703
  }
704
+ let { path } = pattern;
705
+ let optionalSegments = 0;
706
+ for (let index = path.indexOf("?"); index !== -1; index = path.indexOf("?", index + 1)) {
707
+ if (++optionalSegments > MAX_OPTIONAL_PATH_SEGMENTS) {
708
+ throw new Error(
709
+ `Path pattern ${JSON.stringify(path)} exceeds the limit of ${MAX_OPTIONAL_PATH_SEGMENTS} optional segments.`
710
+ );
711
+ }
712
+ }
656
713
  let [matcher, compiledParams] = compilePath(
657
- pattern.path,
714
+ path,
658
715
  pattern.caseSensitive,
659
716
  pattern.end
660
717
  );
@@ -874,6 +931,7 @@ function data(data2, init) {
874
931
  );
875
932
  }
876
933
  var redirect = (url, init = 302) => {
934
+ validateDocumentNavigationTarget(url);
877
935
  let responseInit = init;
878
936
  if (typeof responseInit === "number") {
879
937
  responseInit = { status: responseInit };
@@ -2227,6 +2285,10 @@ function normalizeRelativeRoutingRedirectResponse(response, request, routeId, ma
2227
2285
  location,
2228
2286
  "Redirects returned/thrown from loaders/actions must have a Location header"
2229
2287
  );
2288
+ validateNavigationTarget(
2289
+ location,
2290
+ location,
2291
+ new URL(request.url));
2230
2292
  if (!isAbsoluteUrl(location)) {
2231
2293
  let trimmedMatches = matches.slice(
2232
2294
  0,
@@ -2801,7 +2863,7 @@ async function matchRSCServerRequest({
2801
2863
  }
2802
2864
  const leafMatch = matches?.[matches.length - 1];
2803
2865
  if (!isDataRequest && leafMatch && !leafMatch.route.Component && !leafMatch.route.ErrorBoundary) {
2804
- return generateResourceResponse(
2866
+ let response2 = await generateResourceResponse(
2805
2867
  routerRequest,
2806
2868
  routes,
2807
2869
  basename,
@@ -2809,6 +2871,7 @@ async function matchRSCServerRequest({
2809
2871
  requestContext,
2810
2872
  onError
2811
2873
  );
2874
+ return normalizeResourceResponse(request, response2);
2812
2875
  }
2813
2876
  let response = await generateRenderResponse(
2814
2877
  routerRequest,
@@ -2829,6 +2892,20 @@ async function matchRSCServerRequest({
2829
2892
  response.headers.set("X-Remix-Response", "yes");
2830
2893
  return response;
2831
2894
  }
2895
+ function normalizeResourceResponse(request, response) {
2896
+ if (request.method === "HEAD") {
2897
+ response.body?.cancel().catch(() => {
2898
+ });
2899
+ let headers = new Headers(response.headers);
2900
+ headers.set("React-Router-Resource", "true");
2901
+ return new Response(null, {
2902
+ status: response.status,
2903
+ statusText: response.statusText,
2904
+ headers
2905
+ });
2906
+ }
2907
+ return response;
2908
+ }
2832
2909
  async function generateManifestResponse(routes, basename, request, generateResponse, temporaryReferences, routeDiscovery) {
2833
2910
  let url = new URL(request.url);
2834
2911
  if (url.toString().length > URL_LIMIT) {
@@ -3027,6 +3104,17 @@ async function generateResourceResponse(request, routes, basename, routeId, requ
3027
3104
  }
3028
3105
  }
3029
3106
  async function generateRenderResponse(request, routes, basename, isDataRequest, decodeReply, requestContext, loadServerAction, decodeAction, decodeFormState, onError, generateResponse, temporaryReferences, allowedActionOrigins, routeDiscovery) {
3107
+ if (isMutationMethod(request.method)) {
3108
+ try {
3109
+ throwIfPotentialCSRFAttack(request, allowedActionOrigins);
3110
+ } catch (error) {
3111
+ onError?.(error);
3112
+ return new Response("Bad Request", {
3113
+ status: 400,
3114
+ headers: { "React-Router-Resource": "true" }
3115
+ });
3116
+ }
3117
+ }
3030
3118
  let statusCode = 200;
3031
3119
  let url = new URL(request.url);
3032
3120
  let isSubmission = isMutationMethod(request.method);
@@ -3053,59 +3141,45 @@ async function generateRenderResponse(request, routes, basename, isDataRequest,
3053
3141
  async generateMiddlewareResponse(query) {
3054
3142
  let formState;
3055
3143
  let skipRevalidation = false;
3056
- let potentialCSRFAttackError;
3057
3144
  if (isMutationMethod(request.method)) {
3058
- try {
3059
- throwIfPotentialCSRFAttack(request, allowedActionOrigins);
3060
- } catch (error) {
3061
- onError?.(error);
3062
- potentialCSRFAttackError = error;
3063
- request = new Request(request.url, {
3064
- method: "GET",
3065
- headers: request.headers,
3066
- signal: request.signal
3067
- });
3145
+ ctx.runningAction = true;
3146
+ let result2 = await processServerAction(
3147
+ request,
3148
+ basename,
3149
+ decodeReply,
3150
+ loadServerAction,
3151
+ decodeAction,
3152
+ decodeFormState,
3153
+ onError,
3154
+ temporaryReferences
3155
+ ).finally(() => {
3156
+ ctx.runningAction = false;
3157
+ });
3158
+ if (isResponse(result2)) {
3159
+ return generateRedirectResponse(
3160
+ result2,
3161
+ actionResult,
3162
+ basename,
3163
+ isDataRequest,
3164
+ generateResponse,
3165
+ temporaryReferences,
3166
+ ctx.redirect?.headers
3167
+ );
3068
3168
  }
3069
- if (!potentialCSRFAttackError) {
3070
- ctx.runningAction = true;
3071
- let result2 = await processServerAction(
3072
- request,
3169
+ skipRevalidation = result2?.skipRevalidation ?? false;
3170
+ actionResult = result2?.actionResult;
3171
+ formState = result2?.formState;
3172
+ request = result2?.revalidationRequest ?? request;
3173
+ if (ctx.redirect) {
3174
+ return generateRedirectResponse(
3175
+ ctx.redirect,
3176
+ actionResult,
3073
3177
  basename,
3074
- decodeReply,
3075
- loadServerAction,
3076
- decodeAction,
3077
- decodeFormState,
3078
- onError,
3079
- temporaryReferences
3080
- ).finally(() => {
3081
- ctx.runningAction = false;
3082
- });
3083
- if (isResponse(result2)) {
3084
- return generateRedirectResponse(
3085
- result2,
3086
- actionResult,
3087
- basename,
3088
- isDataRequest,
3089
- generateResponse,
3090
- temporaryReferences,
3091
- ctx.redirect?.headers
3092
- );
3093
- }
3094
- skipRevalidation = result2?.skipRevalidation ?? false;
3095
- actionResult = result2?.actionResult;
3096
- formState = result2?.formState;
3097
- request = result2?.revalidationRequest ?? request;
3098
- if (ctx.redirect) {
3099
- return generateRedirectResponse(
3100
- ctx.redirect,
3101
- actionResult,
3102
- basename,
3103
- isDataRequest,
3104
- generateResponse,
3105
- temporaryReferences,
3106
- void 0
3107
- );
3108
- }
3178
+ isDataRequest,
3179
+ generateResponse,
3180
+ temporaryReferences,
3181
+ void 0
3182
+ );
3109
3183
  }
3110
3184
  }
3111
3185
  let staticContext = await query(
@@ -3123,11 +3197,6 @@ async function generateRenderResponse(request, routes, basename, isDataRequest,
3123
3197
  ctx.redirect?.headers
3124
3198
  );
3125
3199
  }
3126
- if (potentialCSRFAttackError) {
3127
- staticContext.errors ?? (staticContext.errors = {});
3128
- staticContext.errors[staticContext.matches[0].route.id] = potentialCSRFAttackError;
3129
- staticContext.statusCode = 400;
3130
- }
3131
3200
  return generateStaticContextResponse(
3132
3201
  routes,
3133
3202
  basename,
@@ -3535,7 +3604,9 @@ function href(path, ...args) {
3535
3604
  result += "/" + value;
3536
3605
  }
3537
3606
  }
3538
- return result || "/";
3607
+ result = result.replace(/^[\\/]{2,}/, "/") || "/";
3608
+ validateDocumentNavigationTarget(result);
3609
+ return result;
3539
3610
  }
3540
3611
  function trimTrailingSplat(path) {
3541
3612
  let i = path.length - 1;