react-router 7.18.4 → 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 (60) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/development/{browser-eq4RgLsD.d.ts → browser-7x6a6gQP.d.ts} +1 -1
  3. package/dist/development/{browser-BR5QG7ZC.d.mts → browser-CiGxXXOl.d.mts} +1 -1
  4. package/dist/development/{chunk-LVPI3KDG.js → chunk-3QTLHDUO.js} +7 -7
  5. package/dist/{production/chunk-G2MPF4YY.mjs → development/chunk-E2PF4K4Z.mjs} +25 -7
  6. package/dist/development/{chunk-HQO5H5CC.js → chunk-QM7ETCUK.js} +109 -104
  7. package/dist/development/{chunk-GR4NQCSD.js → chunk-S47XUPN5.js} +133 -66
  8. package/dist/development/{chunk-OB3PAWPO.mjs → chunk-YDNE64FV.mjs} +135 -64
  9. package/dist/{production/context-nqAapj74.d.mts → development/context-BlYKn1tE.d.mts} +2 -0
  10. package/dist/development/dom-export.d.mts +2 -2
  11. package/dist/development/dom-export.d.ts +2 -2
  12. package/dist/development/dom-export.js +37 -35
  13. package/dist/development/dom-export.mjs +6 -4
  14. package/dist/development/{index-react-server-client-BjY-eKuf.d.ts → index-react-server-client-BaaZU3sM.d.ts} +1 -1
  15. package/dist/development/{index-react-server-client-K63fpMH4.d.mts → index-react-server-client-KK-TR-t7.d.mts} +1 -1
  16. package/dist/development/index-react-server-client.d.mts +2 -2
  17. package/dist/development/index-react-server-client.d.ts +2 -2
  18. package/dist/development/index-react-server-client.js +4 -4
  19. package/dist/development/index-react-server-client.mjs +2 -2
  20. package/dist/development/index-react-server.d.mts +2 -0
  21. package/dist/development/index-react-server.d.ts +2 -0
  22. package/dist/development/index-react-server.js +109 -17
  23. package/dist/development/index-react-server.mjs +109 -17
  24. package/dist/development/index.d.mts +7 -7
  25. package/dist/development/index.d.ts +7 -7
  26. package/dist/development/index.js +121 -103
  27. package/dist/development/index.mjs +3 -3
  28. package/dist/{production/instrumentation-B7w3_Eo9.d.ts → development/instrumentation-CPkMwccd.d.ts} +2 -0
  29. package/dist/development/lib/types/internal.js +1 -1
  30. package/dist/development/lib/types/internal.mjs +1 -1
  31. package/dist/production/{browser-eq4RgLsD.d.ts → browser-7x6a6gQP.d.ts} +1 -1
  32. package/dist/production/{browser-BR5QG7ZC.d.mts → browser-CiGxXXOl.d.mts} +1 -1
  33. package/dist/production/{chunk-AOOKMWND.js → chunk-2WUBOUFU.js} +109 -104
  34. package/dist/production/{chunk-QURBR4FZ.js → chunk-3IBQ4CTZ.js} +7 -7
  35. package/dist/production/{chunk-YNGRUB6F.js → chunk-AC65NKOP.js} +133 -66
  36. package/dist/production/{chunk-Q34X6AWR.mjs → chunk-HEAXLYUI.mjs} +135 -64
  37. package/dist/{development/chunk-H4DAEOV7.mjs → production/chunk-JRCXCPLA.mjs} +25 -7
  38. package/dist/{development/context-nqAapj74.d.mts → production/context-BlYKn1tE.d.mts} +2 -0
  39. package/dist/production/dom-export.d.mts +2 -2
  40. package/dist/production/dom-export.d.ts +2 -2
  41. package/dist/production/dom-export.js +37 -35
  42. package/dist/production/dom-export.mjs +6 -4
  43. package/dist/production/{index-react-server-client-BjY-eKuf.d.ts → index-react-server-client-BaaZU3sM.d.ts} +1 -1
  44. package/dist/production/{index-react-server-client-K63fpMH4.d.mts → index-react-server-client-KK-TR-t7.d.mts} +1 -1
  45. package/dist/production/index-react-server-client.d.mts +2 -2
  46. package/dist/production/index-react-server-client.d.ts +2 -2
  47. package/dist/production/index-react-server-client.js +4 -4
  48. package/dist/production/index-react-server-client.mjs +2 -2
  49. package/dist/production/index-react-server.d.mts +2 -0
  50. package/dist/production/index-react-server.d.ts +2 -0
  51. package/dist/production/index-react-server.js +109 -17
  52. package/dist/production/index-react-server.mjs +109 -17
  53. package/dist/production/index.d.mts +7 -7
  54. package/dist/production/index.d.ts +7 -7
  55. package/dist/production/index.js +121 -103
  56. package/dist/production/index.mjs +3 -3
  57. package/dist/{development/instrumentation-B7w3_Eo9.d.ts → production/instrumentation-CPkMwccd.d.ts} +2 -0
  58. package/dist/production/lib/types/internal.js +1 -1
  59. package/dist/production/lib/types/internal.mjs +1 -1
  60. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.18.4
2
+ * react-router v7.18.6
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -386,6 +386,67 @@ function createBrowserURLImpl(windowImpl, to, isAbsolute = false) {
386
386
  return new URL(href, base);
387
387
  }
388
388
 
389
+ // lib/router/navigation.ts
390
+ var DEFAULT_NAVIGATION_URL = new URL("http://localhost");
391
+ function getNavigatorCurrentUrl(navigator) {
392
+ if (navigator.createURL) {
393
+ return navigator.createURL("/");
394
+ }
395
+ try {
396
+ return new URL(navigator.createHref("/"), DEFAULT_NAVIGATION_URL);
397
+ } catch {
398
+ return DEFAULT_NAVIGATION_URL;
399
+ }
400
+ }
401
+ function isSameOrigin(a, b) {
402
+ return a.origin === b.origin && (a.origin !== "null" || a.protocol === b.protocol && a.host === b.host);
403
+ }
404
+ function isExplicitUrl(destination, target) {
405
+ if (destination.startsWith("//")) {
406
+ return true;
407
+ }
408
+ let protocol = target.protocol.toLowerCase();
409
+ if (!destination.toLowerCase().startsWith(protocol)) {
410
+ return false;
411
+ }
412
+ return target.host === "" || destination.slice(protocol.length).startsWith("//");
413
+ }
414
+ function validateDocumentNavigationTarget(destination) {
415
+ let normalized = destination.replace(/[\t\n\r]/g, "");
416
+ let start = 0;
417
+ while (normalized.charCodeAt(start) <= 32) start++;
418
+ normalized = normalized.slice(start);
419
+ if (!ABSOLUTE_URL_REGEX.test(normalized)) return;
420
+ let target;
421
+ try {
422
+ target = new URL(destination, DEFAULT_NAVIGATION_URL);
423
+ } catch {
424
+ return;
425
+ }
426
+ if (!isExplicitUrl(destination, target)) {
427
+ throw new Error("External navigation is not allowed");
428
+ }
429
+ }
430
+ function validateNavigationTarget(original, resolved, currentUrl, externalPolicy) {
431
+ let originalUrl = null;
432
+ try {
433
+ originalUrl = original == null ? null : new URL(original, currentUrl);
434
+ } catch {
435
+ }
436
+ let resolvedUrl = new URL(resolved, currentUrl);
437
+ let originalIsExternal = originalUrl != null && !isSameOrigin(originalUrl, currentUrl);
438
+ let resolvedIsExternal = !isSameOrigin(resolvedUrl, currentUrl);
439
+ if (externalPolicy === "reject") {
440
+ if (originalIsExternal || resolvedIsExternal) {
441
+ throw new Error("External navigation is not allowed");
442
+ }
443
+ } else if (resolvedIsExternal) {
444
+ if (originalUrl == null || !isExplicitUrl(original, originalUrl) || !isSameOrigin(originalUrl, resolvedUrl)) {
445
+ throw new Error("External navigation is not allowed");
446
+ }
447
+ }
448
+ }
449
+
389
450
  // lib/router/utils.ts
390
451
  function createContext(defaultValue) {
391
452
  return { defaultValue };
@@ -767,7 +828,12 @@ function generatePath(originalPath, params = {}) {
767
828
  }
768
829
  return segment.replace(/\?$/g, "");
769
830
  }).filter((segment) => !!segment);
770
- return prefix + segments.join("/");
831
+ let result = (prefix + segments.join("/")).replace(/^[\\/]{2,}/, "/");
832
+ if (!prefix && (path.startsWith(":") || path === "*")) {
833
+ result = result.replace(/^([a-z][a-z0-9+.-]*):/i, "$1%3A");
834
+ }
835
+ validateDocumentNavigationTarget(result);
836
+ return result;
771
837
  }
772
838
  function matchPath(pattern, pathname) {
773
839
  if (typeof pattern === "string") {
@@ -995,6 +1061,7 @@ function data(data2, init) {
995
1061
  );
996
1062
  }
997
1063
  var redirect = (url, init = 302) => {
1064
+ validateDocumentNavigationTarget(url);
998
1065
  let responseInit = init;
999
1066
  if (typeof responseInit === "number") {
1000
1067
  responseInit = { status: responseInit };
@@ -1350,51 +1417,6 @@ function isPlainObject(thing) {
1350
1417
  return proto === Object.prototype || proto === null || Object.getOwnPropertyNames(proto).sort().join("\0") === objectProtoNames;
1351
1418
  }
1352
1419
 
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 {
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 {
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
-
1398
1420
  // lib/router/router.ts
1399
1421
  var validMutationMethodsArr = [
1400
1422
  "POST",
@@ -2527,6 +2549,12 @@ function createRouter(init) {
2527
2549
  routeId,
2528
2550
  opts?.relative
2529
2551
  );
2552
+ validateNavigationTarget(
2553
+ null,
2554
+ normalizedPath,
2555
+ init.history.createURL("/"),
2556
+ "reject"
2557
+ );
2530
2558
  let matches = matchRoutesImpl(
2531
2559
  routesToUse,
2532
2560
  normalizedPath,
@@ -3538,6 +3566,10 @@ function createStaticHandler(routes, opts) {
3538
3566
  manifest
3539
3567
  );
3540
3568
  let routeBranches = flattenAndRankRoutes(dataRoutes);
3569
+ let matchCost = routeBranches.reduce(
3570
+ (total, branch) => total + branch.routesMeta.length,
3571
+ 0
3572
+ );
3541
3573
  async function query(request, {
3542
3574
  requestContext,
3543
3575
  filterMatchesToLoad,
@@ -4159,6 +4191,7 @@ function createStaticHandler(routes, opts) {
4159
4191
  }
4160
4192
  return {
4161
4193
  dataRoutes,
4194
+ _matchCost: matchCost,
4162
4195
  _internalRouteBranches: routeBranches,
4163
4196
  query,
4164
4197
  queryRoute
@@ -5292,6 +5325,12 @@ function normalizeRelativeRoutingRedirectResponse(response, request, routeId, ma
5292
5325
  location,
5293
5326
  "Redirects returned/thrown from loaders/actions must have a Location header"
5294
5327
  );
5328
+ validateNavigationTarget(
5329
+ location,
5330
+ location,
5331
+ new URL(request.url),
5332
+ "allow-explicit"
5333
+ );
5295
5334
  if (!isAbsoluteUrl(location)) {
5296
5335
  let trimmedMatches = matches.slice(
5297
5336
  0,
@@ -7823,6 +7862,7 @@ function hydrate(index) {
7823
7862
  set(-0);
7824
7863
  continue;
7825
7864
  }
7865
+ validateIndex(index2, values.length);
7826
7866
  if (hydrated[index2]) {
7827
7867
  set(hydrated[index2]);
7828
7868
  continue;
@@ -7911,6 +7951,7 @@ function hydrate(index) {
7911
7951
  set(obj);
7912
7952
  continue;
7913
7953
  case TYPE_PROMISE:
7954
+ validateIndex(b, values.length);
7914
7955
  if (hydrated[b]) {
7915
7956
  set(hydrated[index2] = hydrated[b]);
7916
7957
  } else {
@@ -7926,6 +7967,7 @@ function hydrate(index) {
7926
7967
  set(error);
7927
7968
  continue;
7928
7969
  case TYPE_PREVIOUS_RESOLVED:
7970
+ validateIndex(b, values.length);
7929
7971
  set(hydrated[index2] = hydrated[b]);
7930
7972
  continue;
7931
7973
  default:
@@ -7990,7 +8032,12 @@ function hydrate(index) {
7990
8032
  }
7991
8033
  ]);
7992
8034
  postRun.push(() => {
7993
- object[r[0]] = r[1];
8035
+ Object.defineProperty(object, r[0], {
8036
+ value: r[1],
8037
+ enumerable: true,
8038
+ configurable: true,
8039
+ writable: true
8040
+ });
7994
8041
  });
7995
8042
  }
7996
8043
  set(object);
@@ -8002,6 +8049,11 @@ function hydrate(index) {
8002
8049
  }
8003
8050
  return result;
8004
8051
  }
8052
+ function validateIndex(index, length) {
8053
+ if (!Number.isSafeInteger(index) || index < 0 || index >= length) {
8054
+ throw new SyntaxError();
8055
+ }
8056
+ }
8005
8057
 
8006
8058
  // vendor/turbo-stream-v2/turbo-stream.ts
8007
8059
  async function decode(readable, options) {
@@ -8108,20 +8160,22 @@ function encode(input, options) {
8108
8160
  };
8109
8161
  const textEncoder = new TextEncoder();
8110
8162
  let lastSentIndex = 0;
8163
+ let cancelled = false;
8111
8164
  const readable = new ReadableStream({
8112
8165
  async start(controller) {
8166
+ const enqueue = (chunk) => {
8167
+ if (!cancelled) controller.enqueue(chunk);
8168
+ };
8113
8169
  const id = await flatten.call(encoder, input);
8114
8170
  if (Array.isArray(id)) {
8115
8171
  throw new Error("This should never happen");
8116
8172
  }
8117
8173
  if (id < 0) {
8118
- controller.enqueue(textEncoder.encode(`${id}
8174
+ enqueue(textEncoder.encode(`${id}
8119
8175
  `));
8120
8176
  } else {
8121
- controller.enqueue(
8122
- textEncoder.encode(`[${encoder.stringified.join(",")}]
8123
- `)
8124
- );
8177
+ enqueue(textEncoder.encode(`[${encoder.stringified.join(",")}]
8178
+ `));
8125
8179
  lastSentIndex = encoder.stringified.length - 1;
8126
8180
  }
8127
8181
  const seenPromises = /* @__PURE__ */ new WeakSet();
@@ -8156,7 +8210,7 @@ function encode(input, options) {
8156
8210
  processingChain = processingChain.then(async () => {
8157
8211
  const id2 = await flatten.call(encoder, resolved);
8158
8212
  if (Array.isArray(id2)) {
8159
- controller.enqueue(
8213
+ enqueue(
8160
8214
  textEncoder.encode(
8161
8215
  `${TYPE_PROMISE}${deferredId}:[["${TYPE_PREVIOUS_RESOLVED}",${id2[0]}]]
8162
8216
  `
@@ -8165,7 +8219,7 @@ function encode(input, options) {
8165
8219
  encoder.index++;
8166
8220
  lastSentIndex++;
8167
8221
  } else if (id2 < 0) {
8168
- controller.enqueue(
8222
+ enqueue(
8169
8223
  textEncoder.encode(
8170
8224
  `${TYPE_PROMISE}${deferredId}:${id2}
8171
8225
  `
@@ -8173,7 +8227,7 @@ function encode(input, options) {
8173
8227
  );
8174
8228
  } else {
8175
8229
  const values = encoder.stringified.slice(lastSentIndex + 1).join(",");
8176
- controller.enqueue(
8230
+ enqueue(
8177
8231
  textEncoder.encode(
8178
8232
  `${TYPE_PROMISE}${deferredId}:[${values}]
8179
8233
  `
@@ -8191,7 +8245,7 @@ function encode(input, options) {
8191
8245
  }
8192
8246
  const id2 = await flatten.call(encoder, reason);
8193
8247
  if (Array.isArray(id2)) {
8194
- controller.enqueue(
8248
+ enqueue(
8195
8249
  textEncoder.encode(
8196
8250
  `${TYPE_ERROR}${deferredId}:[["${TYPE_PREVIOUS_RESOLVED}",${id2[0]}]]
8197
8251
  `
@@ -8200,7 +8254,7 @@ function encode(input, options) {
8200
8254
  encoder.index++;
8201
8255
  lastSentIndex++;
8202
8256
  } else if (id2 < 0) {
8203
- controller.enqueue(
8257
+ enqueue(
8204
8258
  textEncoder.encode(
8205
8259
  `${TYPE_ERROR}${deferredId}:${id2}
8206
8260
  `
@@ -8208,7 +8262,7 @@ function encode(input, options) {
8208
8262
  );
8209
8263
  } else {
8210
8264
  const values = encoder.stringified.slice(lastSentIndex + 1).join(",");
8211
- controller.enqueue(
8265
+ enqueue(
8212
8266
  textEncoder.encode(
8213
8267
  `${TYPE_ERROR}${deferredId}:[${values}]
8214
8268
  `
@@ -8230,8 +8284,11 @@ function encode(input, options) {
8230
8284
  }
8231
8285
  await Promise.all(Object.values(encoder.deferred));
8232
8286
  await processingChain;
8233
- controller.close();
8287
+ if (!cancelled) controller.close();
8234
8288
  onComplete?.();
8289
+ },
8290
+ cancel() {
8291
+ cancelled = true;
8235
8292
  }
8236
8293
  });
8237
8294
  return readable;
@@ -9481,6 +9538,13 @@ function getPathsWithAncestors(paths) {
9481
9538
  function isFogOfWarEnabled(routeDiscovery, ssr) {
9482
9539
  return routeDiscovery.mode === "lazy" && ssr === true;
9483
9540
  }
9541
+ var MANIFEST_MATCH_COST_LIMIT = 5e4;
9542
+ var MANIFEST_MATCH_COST_SEGMENT_THRESHOLD = 10;
9543
+ function shouldUseInitialRouteDiscovery(pathname, matchCost = 0) {
9544
+ let segmentCount = pathname.split("/").length - 1;
9545
+ let ancestorCount = Math.max(segmentCount - 1, 0);
9546
+ return ancestorCount * pathname.length + 1 > URL_LIMIT || segmentCount > MANIFEST_MATCH_COST_SEGMENT_THRESHOLD && segmentCount * matchCost > MANIFEST_MATCH_COST_LIMIT;
9547
+ }
9484
9548
  function getPartialManifest({ sri, ...manifest }, router) {
9485
9549
  let routeIds = new Set(router.state.matches.map((m) => m.route.id));
9486
9550
  let segments = router.state.location.pathname.split("/").filter(Boolean);
@@ -10408,7 +10472,7 @@ var isBrowser2 = typeof window !== "undefined" && typeof window.document !== "un
10408
10472
  try {
10409
10473
  if (isBrowser2) {
10410
10474
  window.__reactRouterVersion = // @ts-expect-error
10411
- "7.18.4";
10475
+ "7.18.6";
10412
10476
  }
10413
10477
  } catch (e) {
10414
10478
  }
@@ -10657,6 +10721,8 @@ var Link = React10.forwardRef(
10657
10721
  }
10658
10722
  }
10659
10723
  let isSpaLink = !(parsed.isExternal || reloadDocument);
10724
+ let renderedHref = (isSpaLink ? maskedHref : void 0) || parsed.absoluteURL || href;
10725
+ validateDocumentNavigationTarget(renderedHref);
10660
10726
  let link = (
10661
10727
  // eslint-disable-next-line jsx-a11y/anchor-has-content
10662
10728
  /* @__PURE__ */ React10.createElement(
@@ -10664,7 +10730,7 @@ var Link = React10.forwardRef(
10664
10730
  {
10665
10731
  ...rest,
10666
10732
  ...prefetchHandlers,
10667
- href: (isSpaLink ? maskedHref : void 0) || parsed.absoluteURL || href,
10733
+ href: renderedHref,
10668
10734
  onClick: isSpaLink ? handleClick : onClick,
10669
10735
  ref: mergeRefs(forwardedRef, prefetchRef),
10670
10736
  target,
@@ -11030,7 +11096,9 @@ function useFormAction(action, { relative } = {}) {
11030
11096
  if (basename !== "/") {
11031
11097
  path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
11032
11098
  }
11033
- return createPath(path);
11099
+ let formAction = createPath(path);
11100
+ validateDocumentNavigationTarget(formAction);
11101
+ return formAction;
11034
11102
  }
11035
11103
  function useFetcher({
11036
11104
  key
@@ -11566,6 +11634,8 @@ export {
11566
11634
  invariant,
11567
11635
  createPath,
11568
11636
  parsePath,
11637
+ validateDocumentNavigationTarget,
11638
+ validateNavigationTarget,
11569
11639
  createContext,
11570
11640
  RouterContextProvider,
11571
11641
  convertRoutesToDataRoutes,
@@ -11582,7 +11652,6 @@ export {
11582
11652
  ErrorResponseImpl,
11583
11653
  isRouteErrorResponse,
11584
11654
  instrumentHandler,
11585
- validateNavigationTarget,
11586
11655
  IDLE_NAVIGATION,
11587
11656
  IDLE_FETCHER,
11588
11657
  IDLE_BLOCKER,
@@ -11673,6 +11742,8 @@ export {
11673
11742
  shouldHydrateRouteLoader,
11674
11743
  URL_LIMIT,
11675
11744
  getPathsWithAncestors,
11745
+ isFogOfWarEnabled,
11746
+ shouldUseInitialRouteDiscovery,
11676
11747
  getPatchRoutesOnNavigationFunction,
11677
11748
  useFogOFWarDiscovery,
11678
11749
  getManifestPath,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.18.4
2
+ * react-router v7.18.6
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -39,6 +39,7 @@ import {
39
39
  hasInvalidProtocol,
40
40
  instrumentHandler,
41
41
  isDataWithResponseInit,
42
+ isFogOfWarEnabled,
42
43
  isMutationMethod,
43
44
  isRedirectResponse,
44
45
  isRedirectStatusCode,
@@ -50,13 +51,15 @@ import {
50
51
  redirectDocument,
51
52
  replace,
52
53
  shouldHydrateRouteLoader,
54
+ shouldUseInitialRouteDiscovery,
53
55
  stripBasename,
54
56
  useRouteError,
57
+ validateDocumentNavigationTarget,
55
58
  warnOnce,
56
59
  withComponentProps,
57
60
  withErrorBoundaryProps,
58
61
  withHydrateFallbackProps
59
- } from "./chunk-OB3PAWPO.mjs";
62
+ } from "./chunk-HEAXLYUI.mjs";
60
63
 
61
64
  // lib/dom/ssr/server.tsx
62
65
  import * as React from "react";
@@ -885,7 +888,9 @@ async function singleFetchAction(build, serverMode, staticHandler, request, hand
885
888
  return handleQueryError(error);
886
889
  }
887
890
  } : void 0,
888
- normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
891
+ // Normalize the original request because handlerRequest may already have
892
+ // its .data suffix removed when v8_passThroughRequests is disabled.
893
+ normalizePath: () => getNormalizedPath(request, build.basename, build.future)
889
894
  });
890
895
  return handleQueryResult(result);
891
896
  } catch (error) {
@@ -950,7 +955,9 @@ async function singleFetchLoaders(build, serverMode, staticHandler, request, han
950
955
  return handleQueryError(error);
951
956
  }
952
957
  } : void 0,
953
- normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
958
+ // Normalize the original request because handlerRequest may already have
959
+ // its .data suffix removed when v8_passThroughRequests is disabled.
960
+ normalizePath: () => getNormalizedPath(request, build.basename, build.future)
954
961
  });
955
962
  return handleQueryResult(result);
956
963
  } catch (error) {
@@ -1305,6 +1312,8 @@ function derive(build, mode) {
1305
1312
  );
1306
1313
  }
1307
1314
  if (request.method === "HEAD") {
1315
+ response.body?.cancel().catch(() => {
1316
+ });
1308
1317
  return new Response(null, {
1309
1318
  headers: response.headers,
1310
1319
  status: response.status,
@@ -1475,10 +1484,17 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
1475
1484
  actionData: context.actionData,
1476
1485
  errors: context.errors
1477
1486
  };
1487
+ let routeDiscovery = build.routeDiscovery;
1488
+ if (isFogOfWarEnabled(routeDiscovery, build.ssr) && shouldUseInitialRouteDiscovery(
1489
+ context.location.pathname,
1490
+ staticHandler._matchCost
1491
+ )) {
1492
+ routeDiscovery = { ...routeDiscovery, mode: "initial" };
1493
+ }
1478
1494
  let baseServerHandoff = {
1479
1495
  basename: build.basename,
1480
1496
  future: build.future,
1481
- routeDiscovery: build.routeDiscovery,
1497
+ routeDiscovery,
1482
1498
  ssr: build.ssr,
1483
1499
  isSpaMode: isSpaMode2
1484
1500
  };
@@ -1501,7 +1517,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
1501
1517
  renderMeta: {},
1502
1518
  future: build.future,
1503
1519
  ssr: build.ssr,
1504
- routeDiscovery: build.routeDiscovery,
1520
+ routeDiscovery,
1505
1521
  isSpaMode: isSpaMode2,
1506
1522
  serializeError: (err) => serializeError(err, serverMode)
1507
1523
  };
@@ -1810,7 +1826,9 @@ function href(path, ...args) {
1810
1826
  result += "/" + value;
1811
1827
  }
1812
1828
  }
1813
- return result || "/";
1829
+ result = result.replace(/^[\\/]{2,}/, "/") || "/";
1830
+ validateDocumentNavigationTarget(result);
1831
+ return result;
1814
1832
  }
1815
1833
  function trimTrailingSplat(path) {
1816
1834
  let i = path.length - 1;
@@ -425,6 +425,8 @@ interface StaticHandler {
425
425
  * The set of data routes managed by this handler
426
426
  */
427
427
  dataRoutes: DataRouteObject[];
428
+ /** @private Estimated route metadata visits per regex match. */
429
+ readonly _matchCost?: number;
428
430
  /**
429
431
  * @private
430
432
  * PRIVATE - DO NOT USE
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
- import { a as RouterProviderProps$1, R as RouterInit, C as ClientInstrumentation, b as ClientOnErrorFunction } from './context-nqAapj74.mjs';
3
- export { D as unstable_DecodeActionFunction, a as unstable_DecodeFormStateFunction, b as unstable_DecodeReplyFunction, R as unstable_RSCHydratedRouter, d as unstable_RSCManifestPayload, e as unstable_RSCPayload, f as unstable_RSCRenderPayload, c as unstable_createCallServer } from './browser-BR5QG7ZC.mjs';
2
+ import { a as RouterProviderProps$1, R as RouterInit, C as ClientInstrumentation, b as ClientOnErrorFunction } from './context-BlYKn1tE.mjs';
3
+ export { D as unstable_DecodeActionFunction, a as unstable_DecodeFormStateFunction, b as unstable_DecodeReplyFunction, R as unstable_RSCHydratedRouter, d as unstable_RSCManifestPayload, e as unstable_RSCPayload, f as unstable_RSCRenderPayload, c as unstable_createCallServer } from './browser-CiGxXXOl.mjs';
4
4
  import './data-DEjBmEfD.mjs';
5
5
 
6
6
  type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { RouterProviderProps as RouterProviderProps$1, RouterInit, ClientOnErrorFunction } from 'react-router';
3
- import { C as ClientInstrumentation } from './instrumentation-B7w3_Eo9.js';
4
- export { D as unstable_DecodeActionFunction, a as unstable_DecodeFormStateFunction, b as unstable_DecodeReplyFunction, R as unstable_RSCHydratedRouter, d as unstable_RSCManifestPayload, e as unstable_RSCPayload, f as unstable_RSCRenderPayload, c as unstable_createCallServer } from './browser-eq4RgLsD.js';
3
+ import { C as ClientInstrumentation } from './instrumentation-CPkMwccd.js';
4
+ export { D as unstable_DecodeActionFunction, a as unstable_DecodeFormStateFunction, b as unstable_DecodeReplyFunction, R as unstable_RSCHydratedRouter, d as unstable_RSCManifestPayload, e as unstable_RSCPayload, f as unstable_RSCRenderPayload, c as unstable_createCallServer } from './browser-7x6a6gQP.js';
5
5
  import './data-CjO11-hU.js';
6
6
 
7
7
  type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;