MCPcopy Create free account
hub / github.com/vercel/vercel / normalizePrefetches

Function normalizePrefetches

packages/next/src/utils.ts:4725–4738  ·  view source on GitHub ↗
(prefetches: Record<string, FileFsRef>)

Source from the content-addressed store, hash-verified

4723// to avoid any conflict with route matching/resolving, we prefix all prefetches (ie, __index.prefetch.rsc)
4724// this is to ensure that prefetches are never matched for things like a greedy match on `index.{ext}`
4725export function normalizePrefetches(prefetches: Record<string, FileFsRef>) {
4726 const updatedPrefetches: Record<string, FileFsRef> = {};
4727
4728 for (const key in prefetches) {
4729 if (key === 'index.prefetch.rsc') {
4730 const newKey = key.replace(/([^/]+\.prefetch\.rsc)$/, '__$1');
4731 updatedPrefetches[newKey] = prefetches[key];
4732 } else {
4733 updatedPrefetches[key] = prefetches[key];
4734 }
4735 }
4736
4737 return updatedPrefetches;
4738}
4739
4740/**
4741 * Get the postponed state for a route.

Callers 2

utils.test.tsFile · 0.90
serverBuildFunction · 0.90

Calls 1

replaceMethod · 0.80

Tested by

no test coverage detected