react-router 7.18.5 → 7.18.6

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 (36) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/{production/chunk-K3NA4NUH.js → development/chunk-3QTLHDUO.js} +7 -7
  3. package/dist/{production/chunk-IAM5GYT3.mjs → development/chunk-E2PF4K4Z.mjs} +14 -5
  4. package/dist/development/{chunk-NDF5KBLP.js → chunk-QM7ETCUK.js} +109 -104
  5. package/dist/development/{chunk-2ZBLYC7V.js → chunk-S47XUPN5.js} +105 -65
  6. package/dist/development/{chunk-6KYCQHYJ.mjs → chunk-YDNE64FV.mjs} +107 -63
  7. package/dist/development/dom-export.js +37 -35
  8. package/dist/development/dom-export.mjs +6 -4
  9. package/dist/development/index-react-server-client.js +4 -4
  10. package/dist/development/index-react-server-client.mjs +2 -2
  11. package/dist/development/index-react-server.js +72 -3
  12. package/dist/development/index-react-server.mjs +72 -3
  13. package/dist/development/index.d.mts +1 -1
  14. package/dist/development/index.d.ts +1 -1
  15. package/dist/development/index.js +111 -102
  16. package/dist/development/index.mjs +3 -3
  17. package/dist/development/lib/types/internal.js +1 -1
  18. package/dist/development/lib/types/internal.mjs +1 -1
  19. package/dist/production/{chunk-75HN637G.js → chunk-2WUBOUFU.js} +109 -104
  20. package/dist/{development/chunk-IFHLIXZW.js → production/chunk-3IBQ4CTZ.js} +7 -7
  21. package/dist/production/{chunk-HNBICOIU.js → chunk-AC65NKOP.js} +105 -65
  22. package/dist/production/{chunk-7RTFRKQW.mjs → chunk-HEAXLYUI.mjs} +107 -63
  23. package/dist/{development/chunk-JAHXRPFV.mjs → production/chunk-JRCXCPLA.mjs} +14 -5
  24. package/dist/production/dom-export.js +37 -35
  25. package/dist/production/dom-export.mjs +6 -4
  26. package/dist/production/index-react-server-client.js +4 -4
  27. package/dist/production/index-react-server-client.mjs +2 -2
  28. package/dist/production/index-react-server.js +72 -3
  29. package/dist/production/index-react-server.mjs +72 -3
  30. package/dist/production/index.d.mts +1 -1
  31. package/dist/production/index.d.ts +1 -1
  32. package/dist/production/index.js +111 -102
  33. package/dist/production/index.mjs +3 -3
  34. package/dist/production/lib/types/internal.js +1 -1
  35. package/dist/production/lib/types/internal.mjs +1 -1
  36. package/package.json +1 -1
@@ -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.6
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -19,7 +19,7 @@
19
19
 
20
20
 
21
21
 
22
- var _chunk75HN637Gjs = require('./chunk-75HN637G.js');
22
+ var _chunk2WUBOUFUjs = require('./chunk-2WUBOUFU.js');
23
23
 
24
24
 
25
25
 
@@ -34,7 +34,7 @@ var _chunk75HN637Gjs = require('./chunk-75HN637G.js');
34
34
 
35
35
 
36
36
 
37
- var _chunkHNBICOIUjs = require('./chunk-HNBICOIU.js');
37
+ var _chunkAC65NKOPjs = require('./chunk-AC65NKOP.js');
38
38
 
39
39
 
40
40
 
@@ -58,4 +58,4 @@ var _chunkHNBICOIUjs = require('./chunk-HNBICOIU.js');
58
58
 
59
59
 
60
60
 
61
- exports.BrowserRouter = _chunk75HN637Gjs.BrowserRouter; exports.Form = _chunk75HN637Gjs.Form; exports.HashRouter = _chunk75HN637Gjs.HashRouter; exports.Link = _chunk75HN637Gjs.Link; exports.Links = _chunkHNBICOIUjs.Links; exports.MemoryRouter = _chunkHNBICOIUjs.MemoryRouter; exports.Meta = _chunkHNBICOIUjs.Meta; exports.NavLink = _chunk75HN637Gjs.NavLink; exports.Navigate = _chunkHNBICOIUjs.Navigate; exports.Outlet = _chunkHNBICOIUjs.Outlet; exports.Route = _chunkHNBICOIUjs.Route; exports.Router = _chunkHNBICOIUjs.Router; exports.RouterProvider = _chunkHNBICOIUjs.RouterProvider; exports.Routes = _chunkHNBICOIUjs.Routes; exports.ScrollRestoration = _chunk75HN637Gjs.ScrollRestoration; exports.StaticRouter = _chunk75HN637Gjs.StaticRouter; exports.StaticRouterProvider = _chunk75HN637Gjs.StaticRouterProvider; exports.UNSAFE_AwaitContextProvider = _chunkHNBICOIUjs.AwaitContextProvider; exports.UNSAFE_WithComponentProps = _chunkHNBICOIUjs.WithComponentProps; exports.UNSAFE_WithErrorBoundaryProps = _chunkHNBICOIUjs.WithErrorBoundaryProps; exports.UNSAFE_WithHydrateFallbackProps = _chunkHNBICOIUjs.WithHydrateFallbackProps; exports.unstable_HistoryRouter = _chunk75HN637Gjs.HistoryRouter;
61
+ exports.BrowserRouter = _chunk2WUBOUFUjs.BrowserRouter; exports.Form = _chunk2WUBOUFUjs.Form; exports.HashRouter = _chunk2WUBOUFUjs.HashRouter; exports.Link = _chunk2WUBOUFUjs.Link; exports.Links = _chunkAC65NKOPjs.Links; exports.MemoryRouter = _chunkAC65NKOPjs.MemoryRouter; exports.Meta = _chunkAC65NKOPjs.Meta; exports.NavLink = _chunk2WUBOUFUjs.NavLink; exports.Navigate = _chunkAC65NKOPjs.Navigate; exports.Outlet = _chunkAC65NKOPjs.Outlet; exports.Route = _chunkAC65NKOPjs.Route; exports.Router = _chunkAC65NKOPjs.Router; exports.RouterProvider = _chunkAC65NKOPjs.RouterProvider; exports.Routes = _chunkAC65NKOPjs.Routes; exports.ScrollRestoration = _chunk2WUBOUFUjs.ScrollRestoration; exports.StaticRouter = _chunk2WUBOUFUjs.StaticRouter; exports.StaticRouterProvider = _chunk2WUBOUFUjs.StaticRouterProvider; exports.UNSAFE_AwaitContextProvider = _chunkAC65NKOPjs.AwaitContextProvider; exports.UNSAFE_WithComponentProps = _chunkAC65NKOPjs.WithComponentProps; exports.UNSAFE_WithErrorBoundaryProps = _chunkAC65NKOPjs.WithErrorBoundaryProps; exports.UNSAFE_WithHydrateFallbackProps = _chunkAC65NKOPjs.WithHydrateFallbackProps; exports.unstable_HistoryRouter = _chunk2WUBOUFUjs.HistoryRouter;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.18.5
2
+ * react-router v7.18.6
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-7RTFRKQW.mjs";
35
+ } from "./chunk-HEAXLYUI.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.6
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 };
@@ -874,6 +921,7 @@ function data(data2, init) {
874
921
  );
875
922
  }
876
923
  var redirect = (url, init = 302) => {
924
+ validateDocumentNavigationTarget(url);
877
925
  let responseInit = init;
878
926
  if (typeof responseInit === "number") {
879
927
  responseInit = { status: responseInit };
@@ -2227,6 +2275,10 @@ function normalizeRelativeRoutingRedirectResponse(response, request, routeId, ma
2227
2275
  location,
2228
2276
  "Redirects returned/thrown from loaders/actions must have a Location header"
2229
2277
  );
2278
+ validateNavigationTarget(
2279
+ location,
2280
+ location,
2281
+ new URL(request.url));
2230
2282
  if (!isAbsoluteUrl(location)) {
2231
2283
  let trimmedMatches = matches.slice(
2232
2284
  0,
@@ -2801,7 +2853,7 @@ async function matchRSCServerRequest({
2801
2853
  }
2802
2854
  const leafMatch = matches?.[matches.length - 1];
2803
2855
  if (!isDataRequest && leafMatch && !leafMatch.route.Component && !leafMatch.route.ErrorBoundary) {
2804
- return generateResourceResponse(
2856
+ let response2 = await generateResourceResponse(
2805
2857
  routerRequest,
2806
2858
  routes,
2807
2859
  basename,
@@ -2809,6 +2861,7 @@ async function matchRSCServerRequest({
2809
2861
  requestContext,
2810
2862
  onError
2811
2863
  );
2864
+ return normalizeResourceResponse(request, response2);
2812
2865
  }
2813
2866
  let response = await generateRenderResponse(
2814
2867
  routerRequest,
@@ -2829,6 +2882,20 @@ async function matchRSCServerRequest({
2829
2882
  response.headers.set("X-Remix-Response", "yes");
2830
2883
  return response;
2831
2884
  }
2885
+ function normalizeResourceResponse(request, response) {
2886
+ if (request.method === "HEAD") {
2887
+ response.body?.cancel().catch(() => {
2888
+ });
2889
+ let headers = new Headers(response.headers);
2890
+ headers.set("React-Router-Resource", "true");
2891
+ return new Response(null, {
2892
+ status: response.status,
2893
+ statusText: response.statusText,
2894
+ headers
2895
+ });
2896
+ }
2897
+ return response;
2898
+ }
2832
2899
  async function generateManifestResponse(routes, basename, request, generateResponse, temporaryReferences, routeDiscovery) {
2833
2900
  let url = new URL(request.url);
2834
2901
  if (url.toString().length > URL_LIMIT) {
@@ -3535,7 +3602,9 @@ function href(path, ...args) {
3535
3602
  result += "/" + value;
3536
3603
  }
3537
3604
  }
3538
- return result || "/";
3605
+ result = result.replace(/^[\\/]{2,}/, "/") || "/";
3606
+ validateDocumentNavigationTarget(result);
3607
+ return result;
3539
3608
  }
3540
3609
  function trimTrailingSplat(path) {
3541
3610
  let i = path.length - 1;
@@ -6,7 +6,7 @@ export { BrowserRouter, Form, HashRouter, Link, Links, MemoryRouter, Meta, NavLi
6
6
  import { serialize, parse } from 'cookie';
7
7
 
8
8
  /**
9
- * react-router v7.18.5
9
+ * react-router v7.18.6
10
10
  *
11
11
  * Copyright (c) Remix Software Inc.
12
12
  *
@@ -272,6 +272,53 @@ function isPlainObject(thing) {
272
272
  return proto === Object.prototype || proto === null || Object.getOwnPropertyNames(proto).sort().join("\0") === objectProtoNames;
273
273
  }
274
274
 
275
+ // lib/router/navigation.ts
276
+ var DEFAULT_NAVIGATION_URL = new URL("http://localhost");
277
+ function isSameOrigin(a, b) {
278
+ return a.origin === b.origin && (a.origin !== "null" || a.protocol === b.protocol && a.host === b.host);
279
+ }
280
+ function isExplicitUrl(destination, target) {
281
+ if (destination.startsWith("//")) {
282
+ return true;
283
+ }
284
+ let protocol = target.protocol.toLowerCase();
285
+ if (!destination.toLowerCase().startsWith(protocol)) {
286
+ return false;
287
+ }
288
+ return target.host === "" || destination.slice(protocol.length).startsWith("//");
289
+ }
290
+ function validateDocumentNavigationTarget(destination) {
291
+ let normalized = destination.replace(/[\t\n\r]/g, "");
292
+ let start = 0;
293
+ while (normalized.charCodeAt(start) <= 32) start++;
294
+ normalized = normalized.slice(start);
295
+ if (!ABSOLUTE_URL_REGEX.test(normalized)) return;
296
+ let target;
297
+ try {
298
+ target = new URL(destination, DEFAULT_NAVIGATION_URL);
299
+ } catch {
300
+ return;
301
+ }
302
+ if (!isExplicitUrl(destination, target)) {
303
+ throw new Error("External navigation is not allowed");
304
+ }
305
+ }
306
+ function validateNavigationTarget(original, resolved, currentUrl, externalPolicy) {
307
+ let originalUrl = null;
308
+ try {
309
+ originalUrl = original == null ? null : new URL(original, currentUrl);
310
+ } catch {
311
+ }
312
+ let resolvedUrl = new URL(resolved, currentUrl);
313
+ originalUrl != null && !isSameOrigin(originalUrl, currentUrl);
314
+ let resolvedIsExternal = !isSameOrigin(resolvedUrl, currentUrl);
315
+ if (resolvedIsExternal) {
316
+ if (originalUrl == null || !isExplicitUrl(original, originalUrl) || !isSameOrigin(originalUrl, resolvedUrl)) {
317
+ throw new Error("External navigation is not allowed");
318
+ }
319
+ }
320
+ }
321
+
275
322
  // lib/router/utils.ts
276
323
  function createContext(defaultValue) {
277
324
  return { defaultValue };
@@ -853,6 +900,7 @@ function data(data2, init) {
853
900
  );
854
901
  }
855
902
  var redirect = (url, init = 302) => {
903
+ validateDocumentNavigationTarget(url);
856
904
  let responseInit = init;
857
905
  if (typeof responseInit === "number") {
858
906
  responseInit = { status: responseInit };
@@ -2206,6 +2254,10 @@ function normalizeRelativeRoutingRedirectResponse(response, request, routeId, ma
2206
2254
  location,
2207
2255
  "Redirects returned/thrown from loaders/actions must have a Location header"
2208
2256
  );
2257
+ validateNavigationTarget(
2258
+ location,
2259
+ location,
2260
+ new URL(request.url));
2209
2261
  if (!isAbsoluteUrl(location)) {
2210
2262
  let trimmedMatches = matches.slice(
2211
2263
  0,
@@ -2780,7 +2832,7 @@ async function matchRSCServerRequest({
2780
2832
  }
2781
2833
  const leafMatch = matches?.[matches.length - 1];
2782
2834
  if (!isDataRequest && leafMatch && !leafMatch.route.Component && !leafMatch.route.ErrorBoundary) {
2783
- return generateResourceResponse(
2835
+ let response2 = await generateResourceResponse(
2784
2836
  routerRequest,
2785
2837
  routes,
2786
2838
  basename,
@@ -2788,6 +2840,7 @@ async function matchRSCServerRequest({
2788
2840
  requestContext,
2789
2841
  onError
2790
2842
  );
2843
+ return normalizeResourceResponse(request, response2);
2791
2844
  }
2792
2845
  let response = await generateRenderResponse(
2793
2846
  routerRequest,
@@ -2808,6 +2861,20 @@ async function matchRSCServerRequest({
2808
2861
  response.headers.set("X-Remix-Response", "yes");
2809
2862
  return response;
2810
2863
  }
2864
+ function normalizeResourceResponse(request, response) {
2865
+ if (request.method === "HEAD") {
2866
+ response.body?.cancel().catch(() => {
2867
+ });
2868
+ let headers = new Headers(response.headers);
2869
+ headers.set("React-Router-Resource", "true");
2870
+ return new Response(null, {
2871
+ status: response.status,
2872
+ statusText: response.statusText,
2873
+ headers
2874
+ });
2875
+ }
2876
+ return response;
2877
+ }
2811
2878
  async function generateManifestResponse(routes, basename, request, generateResponse, temporaryReferences, routeDiscovery) {
2812
2879
  let url = new URL(request.url);
2813
2880
  if (url.toString().length > URL_LIMIT) {
@@ -3514,7 +3581,9 @@ function href(path, ...args) {
3514
3581
  result += "/" + value;
3515
3582
  }
3516
3583
  }
3517
- return result || "/";
3584
+ result = result.replace(/^[\\/]{2,}/, "/") || "/";
3585
+ validateDocumentNavigationTarget(result);
3586
+ return result;
3518
3587
  }
3519
3588
  function trimTrailingSplat(path) {
3520
3589
  let i = path.length - 1;
@@ -1445,7 +1445,7 @@ declare class RemixErrorBoundary extends React.Component<RemixErrorBoundaryProps
1445
1445
  error: Error | null;
1446
1446
  location: Location<any>;
1447
1447
  };
1448
- render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
1448
+ render(): string | number | boolean | React.JSX.Element | Iterable<React.ReactNode> | null | undefined;
1449
1449
  }
1450
1450
 
1451
1451
  declare function getPatchRoutesOnNavigationFunction(getRouter: () => Router, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, routeDiscovery: ServerBuild["routeDiscovery"], isSpaMode: boolean, basename: string | undefined): PatchRoutesOnNavigationFunction | undefined;
@@ -1445,7 +1445,7 @@ declare class RemixErrorBoundary extends React.Component<RemixErrorBoundaryProps
1445
1445
  error: Error | null;
1446
1446
  location: Location<any>;
1447
1447
  };
1448
- render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
1448
+ render(): string | number | boolean | React.JSX.Element | Iterable<React.ReactNode> | null | undefined;
1449
1449
  }
1450
1450
 
1451
1451
  declare function getPatchRoutesOnNavigationFunction(getRouter: () => Router, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, routeDiscovery: ServerBuild["routeDiscovery"], isSpaMode: boolean, basename: string | undefined): PatchRoutesOnNavigationFunction | undefined;