-
Notifications
You must be signed in to change notification settings - Fork 27.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for optional catchall with new router #38444
Changes from 9 commits
0ddcedd
1672a77
632acc5
29e95c0
0e899d1
61bbdb1
28886a1
107c6e5
5eb122b
aaffd48
bc45309
4c81c50
1f4a65d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -394,10 +394,12 @@ export async function renderToHTML( | |
|
||
return { | ||
param: segmentParam, | ||
// @ts-expect-error TODO: handle case where value is an array | ||
value: | ||
// TODO: this should only read from `pathParams`. There's an inconsistency where `query` holds params currently which has to be fixed. | ||
pathParams[segmentParam] ?? | ||
(Array.isArray(pathParams[segmentParam]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missed this in the first PR. The |
||
? // @ts-expect-error TODO: handle case where value is an array | ||
pathParams[segmentParam].join('/') | ||
: pathParams[segmentParam]) ?? | ||
(Array.isArray(query[segmentParam]) | ||
? // @ts-expect-error TODO: handle case where value is an array | ||
query[segmentParam].join('/') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ import { format as formatUrl, parse as parseUrl } from 'url' | |
import { getRedirectStatus } from '../lib/load-custom-routes' | ||
import { | ||
NEXT_BUILTIN_DOCUMENT, | ||
NEXT_CLIENT_SSR_ENTRY_SUFFIX, | ||
SERVERLESS_DIRECTORY, | ||
SERVER_DIRECTORY, | ||
STATIC_STATUS_PAGES, | ||
|
@@ -1026,33 +1027,14 @@ export default abstract class Server<ServerOptions extends Options = Options> { | |
const appPathRoutes: Record<string, string> = {} | ||
|
||
Object.keys(this.appPathsManifest || {}).forEach((entry) => { | ||
if (entry.endsWith(NEXT_CLIENT_SSR_ENTRY_SUFFIX)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
return | ||
} | ||
appPathRoutes[normalizeAppPath(entry) || '/'] = entry | ||
}) | ||
return appPathRoutes | ||
} | ||
|
||
protected getAppPathLayouts(pathname: string): string[] { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is no longer used so it was dead code. |
||
const layoutPaths: string[] = [] | ||
|
||
if (this.appPathRoutes) { | ||
const paths = Object.values(this.appPathRoutes) | ||
const parts = pathname.split('/').filter(Boolean) | ||
|
||
for (let i = 1; i < parts.length; i++) { | ||
const layoutPath = `/${parts.slice(0, i).join('/')}/layout` | ||
|
||
if (paths.includes(layoutPath)) { | ||
layoutPaths.push(layoutPath) | ||
} | ||
} | ||
|
||
if (this.appPathRoutes['/layout']) { | ||
layoutPaths.unshift('/layout') | ||
} | ||
} | ||
return layoutPaths | ||
} | ||
|
||
protected async run( | ||
req: BaseNextRequest, | ||
res: BaseNextResponse, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All changes in this file are just renames.