Commit 3a2316ff authored by Jimmy Lai's avatar Jimmy Lai

refactor: use consistent endsWith pattern for PARALLEL_ROUTE_DEFAULT_PATH

parent c9fd7fd9
...@@ -102,17 +102,14 @@ async function createFlightRouterStateFromLoaderTreeImpl( ...@@ -102,17 +102,14 @@ async function createFlightRouterStateFromLoaderTreeImpl(
// that calls notFound(). This tells the client router not to reuse the // that calls notFound(). This tells the client router not to reuse the
// previous page content when navigating to a URL with no matching page. // previous page content when navigating to a URL with no matching page.
// The path comparison uses endsWith because the loader tree stores // The path comparison uses endsWith because the loader tree stores
// absolute filesystem paths while PARALLEL_ROUTE_DEFAULT_PATH is a // paths that may include a prefix before the package-relative portion
// package-relative path (e.g., "next/dist/client/components/builtin/default.js"). // (e.g., "next/dist/client/components/builtin/default.js").
if (segment === DEFAULT_SEGMENT_KEY) { if (segment === DEFAULT_SEGMENT_KEY) {
const { defaultPage } = loaderTree[2] const { defaultPage } = loaderTree[2]
if ( if (
defaultPage !== undefined && defaultPage !== undefined &&
typeof defaultPage[1] === 'string' && typeof defaultPage[1] === 'string' &&
defaultPage[1].endsWith( defaultPage[1].endsWith(PARALLEL_ROUTE_DEFAULT_PATH)
// Strip the leading "next/" from the constant to match absolute paths.
PARALLEL_ROUTE_DEFAULT_PATH.slice('next/'.length)
)
) { ) {
prefetchHints |= PrefetchHint.IsBuiltinNotFoundDefault prefetchHints |= PrefetchHint.IsBuiltinNotFoundDefault
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment