mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-09 21:07:46 +00:00
[next] fix re-mapping logic for index prefetches (#10750)
Follow-up to https://github.com/vercel/vercel/pull/10734 -- but considers that the static prefetch associated with `/` might be inside of a dir such as `index/index.prefetch.rsc`. To avoid any future matching conflicts, this PR updates to prefix all static prefetches
This commit is contained in:
@@ -3120,3 +3120,16 @@ export async function getServerlessPages(params: {
|
||||
|
||||
return { pages, appPaths: normalizedAppPaths };
|
||||
}
|
||||
|
||||
// to avoid any conflict with route matching/resolving, we prefix all prefetches (ie, __index.prefetch.rsc)
|
||||
// this is to ensure that prefetches are never matched for things like a greedy match on `index.{ext}`
|
||||
export function normalizePrefetches(prefetches: Record<string, FileFsRef>) {
|
||||
const updatedPrefetches: Record<string, FileFsRef> = {};
|
||||
|
||||
for (const key in prefetches) {
|
||||
const newKey = key.replace(/([^/]+\.prefetch\.rsc)$/, '__$1');
|
||||
updatedPrefetches[newKey] = prefetches[key];
|
||||
}
|
||||
|
||||
return updatedPrefetches;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user